✅ Extract parameter from string path based on templae...
Hi there is there a lib that can extract the parameter
/some/path/{parameter}/other
from path string ? I need to read it in middleware before any routing... the position the route before param is always same... thx for any help...18 Replies
regex?
or just string slicing, if you know the position
pls example for /some/path/{parameter}/other thx
regex only tell if match not extract or ?
But i need to extract it not check if match
not sure exactly how you want it to behave for short/longer paths
regex will allow you to extract the value just fine
Aaa basicaly there can be wildchard after the arument
so its just the third segment always?
no third the beginning must be equal
/some/path/{parameter}
right
i wanna match all this paths and get parameter argument from them
like this?
highlighted rows are matches, green indicates the extracted value
/some/path/(.+?)/.*
Uuu let me test in code quick
Assuming the param is always enclosed in
{}
, could also use a regex that looks for that specificallyI assumed it was not and was just placeholders
otherwise, absolutely
Works goood
👍
I tonally forgot to thank you.. Thank you