Connecting Tech Pros Worldwide Help | Site Map

how to write a regular expression?

_andrea
Guest
 
Posts: n/a
#1: Jul 17 '05
I'd like to write a regular expression which match all text between two
<h1>.

I mean:

------------ for: ----------------------
<h1>bla bla [...] \t \r bla \n<h1>
------------- is: -----------------------
bla bla [...] \t \r bla \n


--------------- for: -------------------------
<h1><a name="_Toc104895953"></a><a name="_Toc94324108"></a><a
name="_Toc94268497"></a><a name="_Toc94265711"></a><a
name="_Toc94264823"><span
style='mso-bookmark:_Toc94265711'><span
style='mso-bookmark:_Toc94268497'><span
style='mso-bookmark:_Toc94324108'><span
style='mso-bookmark:_Toc104895953'>2. L'ATTIVITA'
CONTRATTUALE DELLA P.A.</span></span></span></span></a></h1>
bla bla...
[...]
text
<h1>
bla bla...
---------------------------- is: -----------------------------------
<a name="_Toc104895953"></a><a name="_Toc94324108"></a><a
name="_Toc94268497"></a><a name="_Toc94265711"></a><a
name="_Toc94264823"><span
style='mso-bookmark:_Toc94265711'><span
style='mso-bookmark:_Toc94268497'><span
style='mso-bookmark:_Toc94324108'><span
style='mso-bookmark:_Toc104895953'>2. L'ATTIVITA'
CONTRATTUALE DELLA P.A.</span></span></span></span></a></h1>
bla bla...
[...]
text



How to write it?
Thank you in advance,
andrea.


BKDotCom
Guest
 
Posts: n/a
#2: Jul 17 '05

re: how to write a regular expression?


/<H1>(.*?)<\/H1>/is

?

_andrea.l
Guest
 
Posts: n/a
#3: Jul 17 '05

re: how to write a regular expression?


How can I use it?
what does it means /is?
this is a perl format, I can use it whith php and how?

Thank you in advance,
Andrea.

"BKDotCom" <bkfake-google@yahoo.com> ha scritto nel messaggio
news:1121358837.631809.134960@g44g2000cwa.googlegr oups.com...[color=blue]
> /<H1>(.*?)<\/H1>/is
>
> ?
>[/color]


Peter van Schie
Guest
 
Posts: n/a
#4: Jul 17 '05

re: how to write a regular expression?


_andrea.l wrote:[color=blue]
> How can I use it?
> what does it means /is?
> this is a perl format, I can use it whith php and how?[/color]

Use preg_match()
With the regular expression and the subject as arguments.
See: http://nl2.php.net/manual/en/function.preg-match.php

--
http://www.phpforums.nl
petermichaux@yahoo.com
Guest
 
Posts: n/a
#5: Jul 17 '05

re: how to write a regular expression?


I think you are looking for this

http://ca3.php.net/preg-match

Closed Thread