I am trying to create a regular expression that matches the operator ^ (xor) as long as it is acting as an operator between two strings and not beeing part of an string.
For example, having a file with these two lines:
'asdfasdf'; 'asdfasd'^'asdflkj';
['asdf', '^', 'asdf'];
only the first one should match as it is the only one where ^ is not part of an string. How can I make a regular expression to match the ^ when it is not inside an string ?
UPDATE: I am using egrep. I need a way to identify when ^ is part of an string or when it is not. My final objective is to find when the xor operator is being used against an string: something like
('[^']'\^.+|.+\^'[^']')
but this matches the second line of my example.
So, it should match strings like:
'asdf1524-sdfaA'^'sdfa322='
'sdfa22_'^$myvar
$myvar^'asAf34%'
BUT it should not match:
['+','*','^','%']
'^'=>2
"afa^sadfa"
UPDATE2: Added one more example to show why the proposed awk solutions do not work. I need to locate the ^
operator when operating with a single quoted string. I want to locate the number of occurences of this in a file and I want to add this check inside a bash script.
Thanks in advance!