how to write a regular expression?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • _andrea

    #1

    how to write a regular expression?

    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="_Toc10489 5953"></a><a name="_Toc94324 108"></a><a
    name="_Toc94268 497"></a><a name="_Toc94265 711"></a><a
    name="_Toc94264 823"><span
    style='mso-bookmark:_Toc94 265711'><span
    style='mso-bookmark:_Toc94 268497'><span
    style='mso-bookmark:_Toc94 324108'><span
    style='mso-bookmark:_Toc10 4895953'>2. L'ATTIVITA'
    CONTRATTUALE DELLA P.A.</span></span></span></span></a></h1>
    bla bla...
    [...]
    text
    <h1>
    bla bla...
    ---------------------------- is: -----------------------------------
    <a name="_Toc10489 5953"></a><a name="_Toc94324 108"></a><a
    name="_Toc94268 497"></a><a name="_Toc94265 711"></a><a
    name="_Toc94264 823"><span
    style='mso-bookmark:_Toc94 265711'><span
    style='mso-bookmark:_Toc94 268497'><span
    style='mso-bookmark:_Toc94 324108'><span
    style='mso-bookmark:_Toc10 4895953'>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

    #2
    Re: how to write a regular expression?

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

    ?

    Comment

    • _andrea.l

      #3
      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.co m> ha scritto nel messaggio
      news:1121358837 .631809.134960@ g44g2000cwa.goo glegroups.com.. .[color=blue]
      > /<H1>(.*?)<\/H1>/is
      >
      > ?
      >[/color]


      Comment

      • Peter van Schie

        #4
        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

        --

        Comment

        • petermichaux@yahoo.com

          #5
          Re: how to write a regular expression?

          I think you are looking for this



          Comment

          Working...