For example, for a string:
http://www/host/a/b/c/topic/d/e/f/topic/last.html
I want to get value of “b” and “c”, which are value of string before FIRST “topic”.
If I use: .+/(.+)/(.+)/topic/(.+), I will get “e” and “f”. I know it is greedy mode, so it matched second “topic”. But if I changed to lazy mode, like .+?/(.+?)/(.+?)/topic/(.+), it was still not working.
I tend to use something more like:
The idea is instead of matching any character, you match up to the next slash. The brackets,
[], define a character class, the tilde,~, means ‘not’, so[^/]matches everything except a slash.