I need to find a regualer expression that contains the following conditions
- Start with /appl/
- Does not end with /
- does not contain a hyphen (-) anywhere
For example:
/appl/test01
Would be wrong:
/appl/test-01
/appl/test01/
/appl/test-01/
I have created the following and it does what I need except for the hyphen part
^\/appl\/[\W-] [/][\W-]|\/appl\/[\W-] $|[^/]$
Thank you in advance
CodePudding user response:
You can consider using
^\/appl\/[^-]*[^-\/]$
See the regex demo. Details:
^- start of string\/appl\/-/appl/string[^-]*- zero or more chars other than-as many as possible[^-\/]- any char other than-and/$- end of string.
