I have a string which could end with either
"/"
or
"/?secure=true"
I need to validate it. I tried this
\b(/(/?secure=true)?)\b
but I get no matches found with the regex.
However, with
^(/(\$secure=true)?)$
match is found. But this wont help in my case as the string that I want to validate will be prefixed with chars something like "thisismystring/" or "thisismystring/?secure=true".
I want to know how to go about this.
Both cases would contain the
So that should not be in the optional part.
You put the optional part in ()?
and escape the question mark with backslash
And to indicate that it should end with that, you put $ at the end