I want to get the thread-id of an url via regex.
The Url can have these states:
- https://mypage.com/threads/an-example-thread/
- https://mypage.com/threads/an-example-thread/page-1
- https://mypage.com/threads/an-example-thread
My pattern . /threads/(. )/.
covers the first two options. Now I need a pattern, that also covers option 3. . /threads/(. )(/. |$)
works. But I use the first group to get the tread-id/name. So how is is possible to create an or-pattern without grouping?
CodePudding user response:
As mentioned in the comments, try to use /threads/([^\/]*)
, that will match all 3.