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: Intermediate:
RE question

 



wjbell2
New User

Jan 24, 2004, 9:27 AM

Post #1 of 6 (1526 views)
RE question Can't Post

I'm trying to match somthing globally in a string. What I need to do is match anything that starts with a ':' and ends with a '<br>'. It should not car about any thml tags that are in between. Right now I use:

$line =~ s/^(: [^<]*)/<span class=quote>$1<\/span>/;

This matches anything until it hits a '<'.

What I need is to match anything until it hits a '<br>'. I tried [^<br>] but I think that means match either <, or b, or r, or >.

How can I do this?

TIA


davorg
Thaumaturge / Moderator

Jan 24, 2004, 12:08 PM

Post #2 of 6 (1523 views)
Re: [wjbell2] RE question [In reply to] Can't Post

The regex that you need is

Code
  /;.+?<br/

If you want to capture the text between ; and <br> then use parentheses

Code
  /;(.+?)<br/

To match all occurances in a given string and capture them in an array, use something like this:

Code
  my @matchs = $string =~ /;(.+?)<br/g;


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


wjbell2
New User

Jan 24, 2004, 6:10 PM

Post #3 of 6 (1520 views)
Re: [davorg] RE question [In reply to] Can't Post

Thanks, it works. I tried that before and it didn't work (the obvious /: (.*)<br>)/ but I changed the way things are in the string in question and now it catches it. IIRC, I had to use the 'anything but' method before ([^<]).

This is for the forum software I've been working on. It's nothing real fancy but it has some pretty good features. Everyone's pretty helpful here and if anyone wants a copy feel free to email me at wjbell@belletc.net and I'll send you one after I update it with this code.

The forum's at:

http://discuss.belletc.net/

Also check out my perl spam filter at:

http://www.belletc.net/index.cgi?page=scripts_mailfilter


(This post was edited by wjbell2 on Jan 24, 2004, 6:15 PM)


Recall
Novice

Jan 27, 2004, 9:13 AM

Post #4 of 6 (1512 views)
Re: [wjbell2] RE question [In reply to] Can't Post

Depending of course on the target market of your discussion board, it looks like you have a long way to go before you arrive at something similar to vbulletin or phpbb.



I took a quick look at the mail filter and there are some areas for improvement - there are also parts when you use error checking but fail to provide any usefull debugging details, such as:

open( ) || die;


wjbell2
New User

Jan 27, 2004, 2:10 PM

Post #5 of 6 (1505 views)
Re: [Recall] RE question [In reply to] Can't Post

Thanks for looking.

Well, I'm not trying to compete with vbulletin or phpbb. I just made a board for my needs and decided to pass it along here if anyone needed/wanted it.

Mail filter works really well... everything needs improvement.


Recall
Novice

Jan 28, 2004, 1:55 AM

Post #6 of 6 (1503 views)
Re: [wjbell2] RE question [In reply to] Can't Post


Quote
everything needs improvement



Apart from pepperoni pizza Wink

 
 


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

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