Reputation: 870
in my bash script I use a regexp to match a string of variable assignment, for instance:
the regexp i developed: \s*${varName}\s*\={0,1}\s*.*\s*;{0,1}
this regexp can match every instances above but also another instance that I don't want, which is VarValue
I cannot think of a way to make my regexp to not match the VarValue instance.
Upvotes: 1
Views: 235
Reputation: 2698
\s*{varName}(?:\s*=\s*|\s+)(\w+)
I didn't modify your regex since it seemed quite complicated for the job, but this one will match all cases listed above while not matching VarValue
. Your data will be in group 1.
Upvotes: 2