Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Need help to build this regular expression

Last post 07-07-2008, 12:19 PM by ddrudik. 1 replies.
Sort Posts: Previous Next
  •  07-07-2008, 11:51 AM 43819

    Need help to build this regular expression

    Hi everybody

     my name is Eloine

     & i am having problem to match a string character ...

     could you help me please

     Here is the group of character 

    I need a regular expression to match it from start to end of the string

     "         <br><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>"

     please note, that i will use it in my PHP program

     thanks

    Eloine
  •  07-07-2008, 12:19 PM 43820 in reply to 43819

    Re: Need help to build this regular expression

    <?php
    $sourcestring="test         <br><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>test";
    preg_match_all('/         <br><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>/',$sourcestring,$matches);
    echo "<pre>".print_r($matches,true);
    ?>

    or if you want to use a shorter version of the same pattern:

    <?php
    $sourcestring="your source string";
    preg_match_all('/ {9}(<br>)\1(&nbsp;){4} \1\2{8} \1\1/',$sourcestring,$matches);
    echo "<pre>".print_r($matches,true);
    ?>


View as RSS news feed in XML