the result of this match should be only one line: /next whatevertext (given that "whatevertext" is also the same in all the 3 lines) this is because "\next", "\Next" and "\next\" are all similar and I want only the one lowercase with no slash at the end.

The last two lines are selected as well, because "/next/next" and "/next/" are different.

My attempted regex Pattern is:

Code

/((.*)(\/)? (.*)){1}/i

So what I did in the pattern is to say zero or more characters (.*), alternatively ending with a slash (\/)? then space then zero or more characters (.*).

Now ((.*)(\/)? (.*)){1} means that all in the bracket happens at most once. And case insensitive is set using i flag ; however upon testing I am not getting the result I am looking for.

I think the problem lies in the fact that I am looking for something that happens at most once but it happens 3 times, so I would only (probably get only the last 2 distinct lines). So how do I go about it? Any help is appreciated.