I am trying to come up with a regex that captures the word zone
in both scenarios below:
txt1='cast("zone" as varchar(100)) as zoneID'
txt2='cast(zone as varchar(100)) as zoneID'
As you can see, the "
is optional. sometimes it appears and sometimes it doesn't. so the regex needs to work in both scenarios.
I have tried the following:
(?<=cast\()"?zone(?=\s|")
but the output is
"zone
when I incorporate the optional quote "?
inside of the positive look behind I get the following message:
(?<=cast\("?)zone(?=\s|")
look-behind requires fixed-width pattern
I think the parenthesis is causing the issue. How can I incorporate the optional quote in the positive look-behind?