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 2 of 2
  1. #1
    New Coder
    Join Date
    May 2010
    Posts
    79
    Thanks
    15
    Thanked 2 Times in 2 Posts

    preg_match_all 2 cases

    Heyyy

    I was trying to get the text between the '.' and ']' and also the text between the two ":

    PHP Code:
    $html '[ACCESSORY_IDs.ACCESSORY_GOGGLES] = "_°í±Û"';

    preg_match_all('/(s.)(.*?)]/'$html$matchesPREG_SET_ORDER);

    foreach (
    $matches as $val) {
        echo 
    "matched: " $val[0] . "<br>";
        echo 
    "part 1: " $val[1] ."<br>";
        echo 
    "part 2: " $val[2] ."<br>";
        echo 
    "part 3: " $val[3] ."<br>";
        echo 
    "part 4: " $val[4] ."<br><br>";

    the code outputs
    matched: s.ACCESSORY_GOGGLES]
    part 1: s.
    part 2: ACCESSORY_GOGGLES
    along with multiple errors but the errors are expected

    I tried to look for a tutorial about the patterns but I haven't found any, I guess I was too dumb to find one. :x

    can someone help me or teach me please?
    Last edited by kenshn111; 02-22-2013 at 10:43 AM. Reason: turns out I can just use | to have multiple patterns :D

  • #2
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    738
    Thanks
    20
    Thanked 85 Times in 85 Posts
    Try

    http://txt2re.com/

    is good for that kind of stuff
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month


  •  

    Posting Permissions

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