SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: A few questions

  1. #1
    SitePoint Zealot DraginX's Avatar
    Join Date
    Mar 2003
    Location
    US
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A few questions

    1. Does different regexes have different meanings? Ex. (.+?), (.*), (.*?)

    2. Where can I find an explanation of the delimter in preg_replace? (Tried php.net)

    Please answer my questions and thank you

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DraginX
    1. Does different regexes have different meanings? Ex. (.+?), (.*), (.*?)
    Yes.

    Quote Originally Posted by DraginX
    2. Where can I find an explanation of the delimter in preg_replace? (Tried php.net)
    http://php.net/pcre

    Quote Originally Posted by php.net
    The syntax for patterns used in these functions closely resembles Perl. The expression should be enclosed in the delimiters, a forward slash (/), for example. Any character can be used for delimiter as long as it's not alphanumeric or backslash (\). If the delimiter character has to be used in the expression itself, it needs to be escaped by backslash. Since PHP 4.0.4, you can also use Perl-style (), {}, [], and <> matching delimiters.
    Cheerios
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Zealot DraginX's Avatar
    Join Date
    Mar 2003
    Location
    US
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THank you and what does the diferent regex's mean?

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, sorry, I thought you were asking *if* they had a different meaning:

    Code:
    (.+?), (.*), (.*?)
    What you've posted above could be interpreted as three different regexes, or one long-string.

    . -- matches a single character
    + -- matches 1 or more of
    ? -- matches 0 or 1 character
    * -- mathces 0 or more characters
    () -- parentheses, store subpatters for future use

    http://php.net/pcre explains much better (and in more detail) that I could
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

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