I’m a beginner to using Regular Expressions, and I’m looking for a pattern that will split a string by a colon that is not preceded by an asterisk.
I found the following pattern which I thought would work, but doesn’t.
[^:]+\\*:[^:]+
(the \* is escaped to work in a Objective-C compiler)
What do I need to change?
You need to use negative look-behind:
This regex matches a
colon(:)that is not preceded by ->(?<!..)a*->[*]. Using*inside a character class, it looses it’s meaning, and just matches a*.