I have two examples:
1.
$ echo "Lorem ipsum dolor sit amet" | awk ‘{gsub(/L[^r]r/,""); print}’
em ipsum dolor sit amet
2.
$ echo "Loorem ipsum dolor sit amet" | awk ‘{gsub(/L[^r]r/,"");
print}’Loorem ipsum dolor sit amet
Why the second example does not work the same as the first?
In the first example, the record of [^r] is treated as a single character? Is it because one "o" is deleted?
L[^r]rmatchesLfollowed by any single character that isn’trfollowed byrlikeLor. To matchLooryou would wantL[^r]+r. The+quantifier means one or more characters that are notr.