Connecting Tech Pros Worldwide Forums | Help | Site Map

RegExp

Otavio
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Guest
 
Posts: n/a
#2: Jul 17 '05

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]

http://uk.php.net/manual/en/pcre.pattern.modifiers.php

--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
John Dunlop
Guest
 
Posts: n/a
#3: Jul 17 '05

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

http://www.cs.tut.fi/~jkorpela/data/utd.html

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
John Wellesz
Guest
 
Posts: n/a
#4: Jul 17 '05

re: RegExp


On 19 mars 2004, Sir teivan@bol.com.br (Otavio) claimed in
news:3b4b1a41.0403191133.5696dc0c@posting.google.c om:
[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.

Closed Thread