Reputation: 1901
I want to capture in the line below only the world
"ArticleDAO"
Note: it.foo.burp can be any package, and the class name can be everything that finishes or not with word "Local".
if Local exists, than must be omitted.
This is my regex:
(.*\.)([\w]+)(?:Local)?
this works for the the second example, but not for the first one because it captures also "Local" ($1)
Upvotes: 1
Views: 1134
Reputation: 786319
You can use this regex with an optional match and a lazy quantifier:
(\w+?)(?:Local)?$
Your match is available in captured group # 1.
(\w+?)
: will match 1 or more word characters (non-greedy)(?:Local)?$
: Will match optional Local
before line end.Upvotes: 1