I want to get the thread-id of an url via regex.
The Url can have these states:
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?
As mentioned in the comments, try to use /threads/([^\/]*)
, that will match all 3.