Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regular expressions

by mce (Curate)
on Oct 30, 2002 at 12:28 UTC ( #209038=note: print w/replies, xml ) Need Help??


in reply to Regular expressions

Hi,

You can of course take an HTML::Parser to do the work for you. This is the best way.

But if you really want your own regexp, I suggest to use 2 parsings, just to maintain readability. I am sure a real regexp expert can do it in one line, but here is my try.

$x="<html>/something/more words<br/></html>"; $x =~ m|<(\w+)>(.*)</\1>|g; print "first is $1\n"; # You can put the <> around it here $2 =~ m|(/\w+/)(.*)<br/>| ; print "second is $1\n"; print "third is $2\n";
It is up to you to store then in arrays, but at least it gives you a hint.

This is really quick and dirty...

updateIt all depends on how much flexibity you want anyway, you can easily play around with the seperators, etc ...
---------------------------
Dr. Mark Ceulemans
Senior Consultant
IT Masters, Belgium

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2023-03-25 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (62 votes). Check out past polls.

    Notices?