Thread: pcre problem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    14
    Ok I have a preg_match problem, and it looks like this:

    preg_match("/^+OK ([0-9]+)/i", '+OK 1 2', $reg_matches)

    This is being called in an if context but that's irrelevant.

    I would expect $reg_matches[0] to then contain "1" but it contains this: "+OK 1+OK 0 0
    "

    does anyone have any idea as to what's going on?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    Alkmaar, The Netherlands
    Posts
    123
    Rep Power
    14
    Have you checked the manual????

    It reads this:

    Description

    int preg_match (string pattern, string subject [, array matches])

    Searches subject for a match to the regular expression given in pattern.

    If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that match the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.

    Thus concluding: matches[1] is the one you are looking for!!!

    ------------------
    Good luck,
    Bas

    ------------------
    E-mail me at: b.vandermeijden@pecoma.nl
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    14
    thanks for that.. hehe i did read it but obviously not that part.

    thanks again.

Similar Threads

  1. Replies: 5
    Last Post: February 2nd, 2005, 12:28 AM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  3. fread problem: doesn t compile php code
    By ghorghor2002 in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 05:25 AM
  4. Wierd problem inserting data with VB6
    By gregquinn in forum MySQL Help
    Replies: 5
    Last Post: February 2nd, 2004, 07:37 AM
  5. weird java problem..please help
    By suwandy in forum Java Help
    Replies: 1
    Last Post: January 26th, 2004, 04:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo