Reputation: 487
So I need to capture individual sub-directories and assign each of them a reference. The reference order doesn't matter, each reference will be checked individually. Here is an example url:
The URL variables (sub-directories) can also be in any order:
here is my regex so far, but it doesn't work.:
^(?:\w+:\/\/)?(?:[\w.-]+)\/?.*$(\/[0-9a-zA-Z-]+\/){0,12}
Upvotes: 0
Views: 101
Reputation: 5233
Try this one:
^(?:\w+:\/\/)?(?:[\w.-]+)?(\/[0-9a-zA-Z-]+){0,12}\/?
If the above one doesn't work, you should do something like this:
^(?:\w+:\/\/)?(?:[\w.-]+)?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?(?:(\/[0-9a-zA-Z-]+))?\/?
Upvotes: 2