Reputation: 569
I want to construct a PCRE regex for following kind of path string:
/root/product/db.main;/root/product/db.part
Please note that there are only two path strings separated by semicolon, that's it.
I was thinking of something like this: [ \t]*([\/\w ._-];+)
but it doesn't seem to work.
Any suggestions?
Thanks in advance.
Upvotes: 0
Views: 182
Reputation: 520938
Try this regex pattern:
^(?:\/\w+)+(?:\.\w+)?(?:;(?:\/\w+)+(?:\.\w+)?)+$
This matches two or more paths, separated by semicolons. If you only want to match exactly two paths, then use this:
^(?:\/\w+)+(?:\.\w+)?(?:;(?:\/\w+)+(?:\.\w+)?)$
Upvotes: 1