CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
correct my regex please?

 



demon01
Novice

May 17, 2008, 9:27 AM

Post #1 of 4 (3596 views)
correct my regex please? Can't Post

$course_name has HTML tags that I need to removes. There are several and not all have closing tags.

This is what I came up with but I was wondering if there was a to make it all one regex expression.

$course_name=~ s/<(\w+)>/ /;
$course_name=~ s/<(\/\w.*)>/ /;
$course_name=~ s/<(\w.*)>/ /;

I am still not clear on how to group expressions.


KevinR
Veteran


May 18, 2008, 8:25 AM

Post #2 of 4 (3562 views)
Re: [demon01] correct my regex please? [In reply to] Can't Post


Code
s/<\/?[^>]+>//g;

-------------------------------------------------


KevinR
Veteran


May 18, 2008, 9:12 AM

Post #3 of 4 (3559 views)
Re: [demon01] correct my regex please? [In reply to] Can't Post


Code
s/    <- beginning of regexp 

<\/? <- search for < followed by none or one /

[^>]+ <- one or more of any characters except >

> <- search for >

//g <- replace the above pattern with nothing. The 'g' finds and replaces all occurances of the pattern in the string



No need for a donation
-------------------------------------------------


(This post was edited by KevinR on May 18, 2008, 9:18 AM)


demon01
Novice

May 18, 2008, 10:06 AM

Post #4 of 4 (3551 views)
Re: [KevinR] correct my regex please? [In reply to] Can't Post

Thanks Kevin, offer stills stands.



Not sure how my PM got double posted.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives