Reputation: 6483
I need to match 2 types of values:
1. Object.Property
2. Object.FuncName("Argument")
For now I try to use something like this:
\w+.\w+(\(.*\))?
\w+.\w+
- makes sure I get expressions like Object.PropertyName
(\(.*\))?
- I get any parentheses with arguments inside. As they are wrapped in parentheses and followed by questionmark this part is optional.
So it may be Object.PropName
or Object.FuncName('SomeArgHere')
When I use this regex against something like this:
Object.FuncName("SomeArg") = 'SomeValue' AND Object.SomeProp = 'AnotherValue'
In regexhero I have 'SomeValue'
AND Object
matched as well.
Instead it should match Object.FuncName("SomeArg")
and Object.SomeProp
Based on the answer from I tried to use \w+\.\w+(\(.*?\))?\s+MayContain(\[.+,?\ ?\])
to match against things like: Obj.Prop MayContain["value"] AND Obj.Func("Test") MayContain["Other"]
. And it match the whole string, in spite of AND
Upvotes: 0
Views: 87
Reputation: 174696
You need to escape the dot so that it would match a literal dot otherwise it would match any character other than a newline character.
\b\w+\.\w+(\(.*?\))?
Update:
The below regex would match both type of strings,
\w+\.\w+(\(.*?\))?(?:\s+MayContain(\[[^]]*\]))?
Upvotes: 1