C
C#8mo ago
trouble_d

✅ 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
Pobiega
Pobiega8mo ago
regex? or just string slicing, if you know the position
trouble_d
trouble_d8mo ago
pls example for /some/path/{parameter}/other thx regex only tell if match not extract or ?
Pobiega
Pobiega8mo ago
No description
trouble_d
trouble_d8mo ago
But i need to extract it not check if match
Pobiega
Pobiega8mo ago
not sure exactly how you want it to behave for short/longer paths regex will allow you to extract the value just fine
trouble_d
trouble_d8mo ago
Aaa basicaly there can be wildchard after the arument
Pobiega
Pobiega8mo ago
so its just the third segment always?
trouble_d
trouble_d8mo ago
no third the beginning must be equal /some/path/{parameter}
Pobiega
Pobiega8mo ago
right
trouble_d
trouble_d8mo ago
i wanna match all this paths and get parameter argument from them
Pobiega
Pobiega8mo ago
No description
Pobiega
Pobiega8mo ago
like this? highlighted rows are matches, green indicates the extracted value /some/path/(.+?)/.*
trouble_d
trouble_d8mo ago
Uuu let me test in code quick
Angius
Angius8mo ago
Assuming the param is always enclosed in {}, could also use a regex that looks for that specifically
Pobiega
Pobiega8mo ago
I assumed it was not and was just placeholders otherwise, absolutely
trouble_d
trouble_d8mo ago
Works goood
Pobiega
Pobiega8mo ago
👍
trouble_d
trouble_d8mo ago
I tonally forgot to thank you.. Thank you