core
core copied to clipboard
match part of url, to either of the provided phrase or word, without making it optional
Hello , i need to do something like the following but i can't seem to get the syntax right or something.
Flight::route("/$langRegex/a-url-part|another-url-part(/@permalink:[0-9a-z\-]+)", function ($permalink) {
//...rest of code
});
so how I need this to behave ->
- First match the languange (a simple e[nl] check )
- Then i want to match either a-url-part or another-url-part
- Then look for the optional parameter inside the parenthesis, that's after either of the options before
i tried
/$langRegex/(a-url-part|another-url-part)(/@permalink:[0-9a-z\-]+)
this kinda does work but it makes the (a-url-part|another-url-part) part , optional which is something i do not want because then any url with just /$langRegex/ will match on this route.
Is there a way to make this work with just the syntax or a regex , without duplicating the block of code?