Results 1 to 3 of 3

Thread: [Resolved] Preg_Match Pattern

Threaded View

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Resolved [Resolved] Preg_Match Pattern

    Hey I have a patteren which will match the [] (bbCode) style tags in a piece of text, but i cannot get it to match the tags if the span over mulitple lines

    PHP Code:
    $string = <<<eof
    sd as da [b][u][i][c]sample text[/c][/i][/u][/b] asd

    fasdf
    [c][small][b]Hello World[/b][/small][/c]

    adhsdaof usdsdiof ;adsljfdf as [u]wow[/u]sdasd
    sdfgsdfs[r]way
     out[/r]
    eof;

    $pattern '/\[.*?\].*?\[\/.*?\]/U';
    $match_count preg_match_all($pattern,$string,$array);
    print_r($array); 
    output
    Code:
    Array
    (
        [0] => Array
            (
                [0] => [b ][u ][i ][c ]sample text[/c ][/i ][/u ][/b ]
                [1] => [c ][small ][b ]Hello World[/b ][/small ][/c ]
                [2] => [u ]wow[/u ]
            )
    
    )

    If anyone can help me match code over multiple lines would be great.

    Thanks
    Last edited by john tindell; Feb 6th, 2006 at 04:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width