-4

I need quick help with regex I have

'http://127.0.0.1:5000/register'

and want to replace it with

`${process.env.API_URL}/register`

doing this regex:

'http://127.0.0.1:5000/.*'

takes the whole thing

6
  • If the string is fixed, what is the point of using regex? Commented Nov 19, 2020 at 8:28
  • what do you mean by fixed? Commented Nov 19, 2020 at 8:28
  • You don't need .*. Just replace http://127.0.0.1:5000/ with ${process.env.API_URL}/ Commented Nov 19, 2020 at 8:30
  • one string starts with ' and other starts with ` Commented Nov 19, 2020 at 8:31
  • not the same type in js Commented Nov 19, 2020 at 8:31

1 Answer 1

3

Use a capture group to copy the part after /

Find: 'http://127.0.0.1:5000/(.*)'

Replace: `${process.env.API_URL}/$1`

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.