help with regexp in gawk file
"Hane, Christopher A" <[email protected]>
| Newsgroups | gmane.comp.windows.gnu.user |
|---|---|
| Message-ID | <9F684AC93EB2D54CA6A9A2E42FB2BB5E039C91E9@APSW0641EVS.ms.ds.uhc.com> |
I am trying to remove all words in one list from another list of words.
If I explicitly enumerate the words to remove everything works fine:
gsub(/to /, "",text);
gsub(/in /, "",text);
gsub(/or /, "",text);
but if I try to build the list of words in an array no substitutions are
ever done. How can I properly format the text array to remove the
words?
Thanks!
BEGIN{
j=0;
badwords[j++]= "/<a> /";
badwords[j++]= "/<the> /";
badwords[j++]= "/<in> /";
text = "a fox jumped into and in the river";
text2 = "a fox jumped into and in the river";
gsub(/\<a\> /, "", text);
gsub(/\<the\> /, "", text);
gsub(/\<in\> /, "", text);
print text;
for (i in badwords)
{
gsub(badwords[i], "", text2);
}
print text2;
exit(0);
};
{
}
END{}
This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf