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

Did you find this page helpful?