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