SitePoint Sponsor

User Tag List

Results 1 to 25 of 48

Hybrid View

  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "Using Regular Expressions in PHP"

  2. #2
    SitePoint Enthusiast Gonik's Avatar
    Join Date
    May 2005
    Location
    Thessaloniki, Greece
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually Quaint's regex would work better if it was:
    Code:
    ^[-a-zA-Z0-9_.]{4,}$
    If you're gonna use dashes (-) inside braces it must be put in the beggining or in the end, because it works like "From * to *", meaning that it would try to much every character between the ASCII representation of underscore (_) and the ASCII representation of the dot (.)
    Don't Drink & Surf The Net

  3. #3
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good explanation! Thank you!

    Quaint Tech
    - Blog on web development and web technology.

  4. #4
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice article. But I have a problem. How do I match a sentence under a quotation? For example, if the text is

    I need you help to 'get sentence under it'. Pleas help me.

    Look at above text. I need to match the sentence which is under the single quotation. Please help me by providing appropriate regular expression.

  5. #5
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,023
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    hkabir, this article is very old (although you may not realise it) and it would be better if you asked in the PHP forum.

    Yet, I will simply tell you that if those single quotation are part of the text you need to look for, you simply escape them with a backslash.

    As an example, you have this sentence

    Code:
    $string="This is a very 'simple sentence' with a bit of text."
    and you want to look for the string 'simple sentece' with which includes those single quotes.

    Code:
    eregi('\'simple sentence\' with', $string)
    Eregi is a function that now is deprecated fo, there is an extension called PRCE based on perl and regular expressions, of course


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
  •