I wrote a regular expression to try and replace a every occurrence of a word not in double quotes using gsub with awk. However even though the expression works with online calculators the expression doesn't replace anything at all in my script.
input =
studentNum=="00000"{print name, "is the prof"}
expression:
gsub( "studentNum(?=[^"]*(?:"[^"]*"[^"]*)*$)", "XXX", input)
expected output:
XXX=="00000"{print name, "is the prof"}