1

Here is my pattern, \/\d+$. It matches the slash and number which is in the end of string. Now I want to expand it and making it working for a sequence of them.

Here is the input:

ticket/2/1/19

And here is the current result:

ticket/2/1

And this is the expected result:

ticket

How can I do that?

Martin AJ
  • 6,261
  • 8
  • 53
  • 111

1 Answers1

1

You may wrap \/\d+ with a grouping construct and quantify the group:

(?:\/\d+)+$

See the regex demo

Details

  • (?: - start of a non-capturing group
    • \/ - a /
    • \d+ - 1+ digits
  • )+ - end of the group, repeated 1 or more times (+)
  • $ - end of string.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563