RegExp

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

    RegExp

    Hello!

    A have a tag <data></data>, but the contente is in multilines. As this:

    <data>
    Bla Bla Bla Bla Bla
    </data>

    If I use $regexp = "/<data>([^>]*)<\/data>/" the RegExp does not work.

    Do u know what can i do?

    Thanks!!!!!!
  • Andy Hassall

    #2
    Re: RegExp

    On 19 Mar 2004 11:33:31 -0800, teivan@bol.com. br (Otavio) wrote:
    [color=blue]
    >A have a tag <data></data>, but the contente is in multilines. As this:
    >
    ><data>
    >Bla Bla Bla Bla Bla
    ></data>
    >
    >If I use $regexp = "/<data>([^>]*)<\/data>/" the RegExp does not work.
    >
    >Do u know what can i do?[/color]

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • John Dunlop

      #3
      Re: RegExp

      Otavio wrote:
      [color=blue]
      > <data>
      > Bla Bla Bla Bla Bla
      > </data>
      >
      > If I use $regexp = "/<data>([^>]*)<\/data>/" the RegExp does not work.[/color]

      What did you try exactly, and why? What happens? and what were you
      expecting? Are ">"s not allowed between tags? If so, I wonder why
      they aren't allowed -- have you created, or are you creating your own
      markup notation? Cool. Here's some food for thought



      Anyhow, the character class [^>] matches newlines, irrespective of
      pattern modifiers. This, to borrow your example, returns true

      preg_match(
      '`<data>([^>]*)</data>`',
      '<data>
      Bla Bla Bla Bla Bla
      </data>')
      [color=blue]
      > Do u know what can i do?[/color]

      No, since I don't know what you're trying to do. Incomplete assumed
      solutions aren't problem descriptions.

      --
      Jock

      Comment

      • John Wellesz

        #4
        Re: RegExp

        On 19 mars 2004, Sir teivan@bol.com. br (Otavio) claimed in
        news:3b4b1a41.0 403191133.5696d c0c@posting.goo gle.com:
        [color=blue]
        > Hello!
        >
        > A have a tag <data></data>, but the contente is in multilines. As this:
        >
        > <data>
        > Bla Bla Bla Bla Bla
        > </data>
        >
        > If I use $regexp = "/<data>([^>]*)<\/data>/" the RegExp does not work.
        >
        > Do u know what can i do?
        >
        > Thanks!!!!!![/color]

        try:

        $regexp = "/<data>(.*)<\/data>/Um";

        U option is for Ungreedy else it'll take everything till the LAST </data>
        tag

        and m is for multilines.

        Comment

        Working...