I have a string, and I want to define if it a correct pathname and that at least one (/:)|(^/?:)
pair of symbols exists and that all in one step.
Correct pathname must include next symbols [a-zA-Z0-9.~!$&'()*+,;=@-_s:] in each portion, divided by ‘/’.
For example:
:param1/path1/:param2
– correct, with defining groups {param1, param2}path1/path2/path3
– incorrectpath1/:param1
– correct, with defining group {param1}
Is it possible to do in one step with a help of regular expression?
2
Answers
I’d probably do it with this regex
:([^/]+)
https://regexr.com/7prjd
have a try:
https://regex101.com/r/8U3oiw/1
maybe this:
https://regex101.com/r/Ennltp/1