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

Did you find this page helpful?