Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Regular Expression Help

by George_Sherston (Vicar)
on Sep 01, 2001 at 13:38 UTC ( #109624=note: print w/replies, xml ) Need Help??

in reply to Regular Expression Help

Other monks may have wiser suggestions: if I were doing this, I'd strip all the codes before putting the text in the array, using something like
$text =~ s/<.+?>//g; push @array, $text;
Then when printing out,
for (@array) {print '<b>' . $_ . '</b>'}
... or whatever other formatting you might want to use.

Not sure this is what you want to do, but if it is, then this will do it. "Those people who like this kind of thing will find it the kind of thing they like", as Abraham Lincoln says.

George Sherston

Replies are listed 'Best First'.
Re: Re: Regular Expression Help
by tlhf (Scribe) on Sep 02, 2001 at 08:46 UTC
    In my own experience, something like s/<\/?\w+(.*?(\".*?\")?(\'.*?\')?)*?>//g is usually nicer for stripping tags, because often >s have a habit of slipping into automatically generated hrefs. And occasionally javascript event properties.

    I'm not definate if the above works perfectly, cause I just hacked it up in a couple of minutes, but it should be ok.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109624]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2021-10-20 18:48 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (81 votes). Check out past polls.