I am using this RegEx to match a word before a colon.
([^\s]+)\:
However, how would I change this so it will only match the word if the line does not begin with a hyphen/dash?
EDIT
Should match:
[object doSomething:foo];
Shouldn’t match:
- (void)doSomething:(NSString *)string;
Should do the trick. (Assuming that the
DOT_ALLmodifier is not used.)Ergo: At least one character before the first colon. First character cannot be a hyphen or colon.
Alternatively
^[^:-][^:]*:\s*if you find that easier to read.EDIT:
According to comment this was what solved OPs problem: