Reputation: 1235
Let's say I have an AWK script, where the string variable my_var
is defined (and equals to ;
-- just in case this matters). Now, I want to delete one or more occurrences of my_var
from another string:
gsub(/my_var+/, "", another_string)
Obviously, this doesn't work. But how should I construct this gsub
command (or, how should I escape my_var
) to make it happen?
Upvotes: 3
Views: 73
Reputation: 785266
You can construct regex using string:
gsub(my_var "+", "", another_string)
Upvotes: 3