I'm trying to come up with a pattern to match a string containing "::" 0 or more times but not to match any strings with a single ":" by itself.
So for instance if the group I'm trying to match is arg in "caller message: arg" and arg is something like Class::method() then it should match. I don't want it to find a single ":" in case the string is "caller message1: arg1 message2: arg2" in which case I'd like the pattern to match both arg1 and arg2 but not confuse arg1 message: arg2 as the string to match.
So I have something like [^\[\]\s:]+[:{2}]+[^\[\]\s:]+|[^\[\]\s:]+ to match the arg section (which is trying to find 0 or 1 occurrence of "::").
Clearly I'm no regex expert (or regexpert (or repert) ;) ) and I'm curious to know what the generalised version of this might look like.
That is, what regex would I need to search for a substring that doesn't appear in any partial form in the pattern. So if I'm looking for "string", then "s", "st", "str" or any substring of "string" that starts at the beginning (a more generalised version could disallow any substring) cannot appear in the match.
The problem with the idea in the above regex is that it doesn't take into account multiple instances of "::" for example in "Class1::method1(Class2::method2())".
I'm looking for an answer specifically for the whole ":" issue but feel free to answer in a generalised form as well.
EDIT:
tl;dr: I want to match Class1::method1(Class2::method2()) in caller message: Class1::method1(Class2::method2()) or match that in addition to Class3::method3(Class4::method4()) in caller message1: Class1::method1(Class2::method2()) message2: Class3::method3(Class4::message4()) (separately) but the pattern mustn't match the Class1::method1(Class2::method2()) message2: Class3::method3(Class4::method4())
EDIT2:
To clarify: pattern must match in "A B: C::D()" the string C::D()
and in A B: C::D() E: F::G()" the strings C::D() and F::G() but not C::D() E: F::G().
I don't think I can be clearer about the intention and why a simple (find me anything)::(anything again) is insufficient.
EDIT3:
Also, there could technically be a space in the part after each : like C::D("some text") which means the regex I mentioned earlier is incorrect and should be more like [^\[\]:]+[:{2}]+[^\[\]:]+|[^\[\]:]+
Here's a real world (modified) example I'm struggling with:
[layer runAction: Sequence::actions(actionScale, NULL)]
which need to match layer, runAction and Sequence::actions(actionScale, NULL) in the complete pattern.
And this:
[Sequence actions: DelayTime::create(1.0), CallFunc::create(this, selector(explodeCells)), NULL] which must match Sequence, actions and DelayTime::create(1.0)..., NULL
And this:
[Analytics reportEvent: GENERAL_EVENT usingID: getCurrentID() withParameter: Number::numberWithFloat(Number::defaultNumber() + 1)] must match Analytics, reportEvent, GENERAL_EVENT, usingID (can be ignored but for simplicity it can be matched as well), getCurrentID(), withParameters (can also be ignored), Number::numberWithFloat(Number::defaultNumber() + 1).
EDIT4:
I changed the final example in EDIT3 to reflect the final objective I'm trying to achieve. Here's a DEMO.