Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2003
    Location
    PHP-LAND
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    regular expressions

    Hello everybody,

    I'm trying to make a function, that finds all strings like "{SOMETHNG:somethingmore}" from HTML-file.

    I tried this:

    PHP Code:
    $str="asdas sd,{INCLUDE_HTML:kall.htm}asd jes jes yehhh sad {INCLUDE_HTML:moon.htm}kall ekpas asda ";
    $str_two="<html><head><title>my page</title>{INCLUDE_HTML:stuff}</head><body>weolcome!!!!<hr> {INCLUDE_HTML:baaad.htm} </body></html>";
    if(
    preg_match_all("/\{INCLUDE_HTML:\w+}\b/",$str,$array)) { 
        
    print_r($array);


    it found only from first string, bot from the second one it didnt find anything...

    but it doesnt find all the occurences and seems strange... has somebody a better idea to do this?
    Last edited by meediake; 01-11-2006 at 11:54 PM.

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Code:
    /{INCLUDE_HTML:(.+?)}/
    $array[0] will be the total match, $array[1] will be just the stuff after the colon

    or, if you're doing multiple tags in the same format,
    Code:
    /{(.+?):(.+?)}/
    $array[0] will be the total match, $array[1] will be the stuff before, and $array[2] the stuff after the colon

  • #3
    New Coder
    Join Date
    Nov 2003
    Location
    PHP-LAND
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    thank you very much, your version works much better


  •  

    Posting Permissions

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