2

I am trying to find a way to match a route when request contains multiple path and URL always end with /end

For example:

domain.com/api/path1/path2/path3/end

domain.com/api/path1/path2/path3/path4/end

I tried [Route("api/{p:regex(([[\\w-]]*\\/){{1,}})}end")] but this didn't work.

Any recommendation?

4
  • What have you tried that didn't work? Commented Oct 3, 2017 at 14:03
  • I tried this but in[Route("api/{p:regex(([[\\w-]]*\\/){{1,}})}end")] this doesnt work :-( Commented Oct 3, 2017 at 14:04
  • Would you edit your question to add the code you used, which didn't work as expected? Commented Oct 3, 2017 at 14:09
  • Done that thank you Commented Oct 3, 2017 at 14:15

1 Answer 1

3

regex pattern must be as below:

^(?:[a-z0-9.]+(\/))*end

Note that in the C# language "\" is the operator character. So you must use \\ instead of \.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.