[Help!] preg_match_all

Discussion in 'PHP' started by kingdolar, Jul 24, 2008.

  1. #1
    can someone tell me what this script mean ?

    preg_match_all("/superdesc(.*?)Starting/s", $d, $M);
    Code (markup):
     
    kingdolar, Jul 24, 2008 IP
  2. ahowell

    ahowell Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    it uses regEx to match "/superdesc(.*?)Starting/s" in the provided string $d, and puts all the matches into the array $M
     
    ahowell, Jul 24, 2008 IP
  3. kingdolar

    kingdolar Well-Known Member

    Messages:
    404
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    133
    #3
    can you give me detail whata mean : "/superdesc(.*?)Starting/s"
     
    kingdolar, Jul 24, 2008 IP
  4. ahowell

    ahowell Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    /superdesc(.*?)Starting/s

    / = delimiter
    ( = Opens the subpattern
    . = match any character except new line
    *? = Match 0 or more times, but as few times as possible.
    ) = Closes the subpattern
    / = delimiter
    s = modifier

    Delimiter = any character that opens/closes the pattern (cannot be used withing the pattern without being escaped)
    Subpattern = what it says
    Modifier = when /s is used, a dot metacharacter (.) in the pattern matches all characters, including newlines. Without it, newlines are excluded.

    Do you have a particular pattern you are trying to work out?
     
    ahowell, Jul 24, 2008 IP
    kingdolar likes this.
  5. kingdolar

    kingdolar Well-Known Member

    Messages:
    404
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    133
    #5
    thanks ahowell.
    rep added.
     
    kingdolar, Jul 24, 2008 IP