Click to See Complete Forum and Search --> : Help needed in filtering a pattern from a text line


cgi_js
05-15-2006, 08:53 PM
Hello

I have a problem with filtering a certain pattern from a line. My line of text carries this parrent:

word1<!--somewordhere--> word2<!--somewordhere--> word3<!--somewordhere--> word4<!--somewordhere--> word5<!--somewordhere--> word6<!--somewordhere--> word7<!--somewordhere-->


And I would like to remove all the <!--somewordhere--> parrents from the line using the "=~ s///;" operator. How can I do that?

Note: The "somewordhere" that is between the "<!--" and "-->" refers to any character or a combination of characters (non-whitespace chars). For example, it could be something like: <!--Hello-->

Any hints?

Nedals
05-15-2006, 09:02 PM
Try this....

$line =~ s/<\!--.+?-->//g;