1

I have url something like this

/test/test123/e/account/data/element?bUnit=17&name=cId&formName=TestForm&value=[self]

I just want to get first querystring and replace value of it so i tried

[\?&]([^=]+)\=([^&]+)

Here is example url https://regex101.com/r/6qCllM/3

But getting all querystrings. I already have tried, just little mistake which want to fix. Don't want multiple lines of function.

How to get only one Query string and replace?

Thanks

4
  • Can you explain what exactly you're trying to select and replace? That whole substring is indeed one query string Commented Oct 5, 2018 at 5:37
  • put your inputs and expected out. Commented Oct 5, 2018 at 5:38
  • 1
    If you only want the first one, then why use &? Change [\?&] to [\?] and it works in your refex101 Commented Oct 5, 2018 at 5:41
  • If you want to find/replace a specific parameter (which sounds much more useful than just the first), then : stackoverflow.com/questions/5999118/… (and many other already answered questions that ask the same thing) Commented Oct 5, 2018 at 5:44

1 Answer 1

2

remove the first &, this should work

[\?]([^=]+)\=([^&]+)
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.