At 7:18 PM 5/20/96, Eric Muehling wrote: >I'm working with some text files that have >style tags like this <styletag>. I want to >write a brief Perl statement that removes >"<>" and any text between the greater and >lesser than symbols. In these text file the >symbols exist in matching pairs. > >My first hack is just too wordy. It does this: > >1. I find the < in each line then copy everything befor it to $Before >2. I find the > in each line then copy everything after it to $After >3. I print $Before and $After (voila! the <styletag> is gone). > >One problem is that my method only works >when there's only ONE <styletag> per line. > >Is a way to get Perl to match <*> (the symbols >and everything between) and delete? I prefer a >wildcard searh because there are many, many ><styletags> to deal with. I don't want to require >exact name matches, just <wildcardtag> matches. > How bout: #!perl open (IN, $in); open (OUT, ">$out"); select (OUT); while (<IN>) { s/<[^>]*>//g; print; } close OUT; close IN; select (STDOUT); The regex matches a <, then anything NOT a > for unlimted chars, then a > then and removes it from the line. Shawn. W3/Perl/C/HTML Programming Consultant for IN Jersey. IN Jersey: The Information Network for the Garden State. http://www.injersey.com/ ------------------------------------------------------------------------- Why do I like Perl? Because "in accordance with Unix theory, it gives you enough rope to hang yourself with." - Programming Perl. Why do I dislike Java? Becuase "I can't find the object/class called ROPE that contains the method called HANG." - Shawn.