Regular expression of any word not preceding a period

I tried several options, but nothing gives me a whole word.

it gives me partial words,

`@"(?<![.])\w+"`

I am parsing C # code, so the string "Regex.Match(" ", " ")"should return Regex, but not match.

As a result, I used only \w+and performed this check,

if ((match.Index > 0) && ('.' == text[match.Index - 1]))
    continue;

Which works fine, but it was just curious if there was a regex that would also do this.

+3
source share
2 answers

You can also try: (?<![.])\b\w+\b

+5
source

try this negative width lookbehind statement option

(?<!(\.\w*))\w+

, , , , , 0 ,

.NET @msdn

+1

All Articles