0

Below is my regex to replace ? chars from a URL.

[?](?![-\w%+]+=|$)

Its working, but with some caveats. If the query parameter name contains characters which are not specified in the regx character set, it breaks.

Any suggestions ?

1
  • 1
    (?![^?]+=|$) would help, I suppose Commented Oct 17, 2014 at 13:20

1 Answer 1

1

You can just use negated class

[?](?![^?]+=|$)

[^?] will look for any character that isn't ?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.