0

I have the following regex to match a line, containing a word, immeditalely followed by a ":", or not immediately.

string(?:.+?(?=\x3a|%3a))(?:\x3a|%3a)

So I want my regex matches :

string:test:test (match string:)

stringanything:test:test (match stringanything:)

But there is an issue with the first line, when the ":" is direclty after the "string", it matches to the 2nd ":", see here : https://regex101.com/r/hqyb3a/2

If I translate, it would be : match the string word and everything before a ":" (even if there is no characters), followed by ":"

I try to make an exception by adding the : in a OR, but it doesn't work, it sounds like it's greedy instead of lazy :

string(?:\x3a|.+?(?=\x3a|%3a))(?:\x3a|%3a)

Can you help me ?

kubongo
  • 1
  • 1

0 Answers0