I have need to get the word between . and )
I am using this: \..*\)
But if there is more than one . I am getting the first . to ) instead of the last . to ).
E.g:
abc.def.ghi.jkl.mymodname(Object sender, CompletedEventArgs e)
I am getting :
def.ghi.jkl.mymodname(Object sender, CompletedEventArgs e)
I want:
mymodname(Object sender, CompletedEventArgs e)
Any pointers?
I’m new to regex, as you can see…
Be explicit. If you don’t want any dots between your starting dot and the closing parenthesis, you can specify this:
[^.]is a negated character class, meaning “any character except a dot”. That way, only non-dots are allowed to match after the dot.And if you don’t want the leading dot to be a part of the match (but do want it to be present before the start of the match), you can use a lookbehind assertion:
This works in nearly all regex engines except for JavaScript and Ruby (until version 1.8), both of which do not support lookbehind.