Connecting Tech Pros Worldwide Help | Site Map

RegExp

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:18 AM
Otavio
Guest
 
Posts: n/a
Default 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!!!!!!

  #2  
Old July 17th, 2005, 04:19 AM
Andy Hassall
Guest
 
Posts: n/a
Default 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
  #3  
Old July 17th, 2005, 04:19 AM
John Dunlop
Guest
 
Posts: n/a
Default 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
  #4  
Old July 17th, 2005, 04:20 AM
John Wellesz
Guest
 
Posts: n/a
Default 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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.