SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    P Town
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with simple regex

    Ok, I am terrible at regex patterns an have been driving myself nuts trying to get this one.

    I am trying to match somthing like
    [quote="this is a username"]

    so far this is my regex but I am having no luck
    Code:
    eregi_replace('/(\[quote){1}(=){1}(")?([.]+)(")?\]{1}/', '[$1]', $post_txt)
    Evrytime I work with regex it seems like I have to relearn it all over

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code php:
    preg_match('#\[quote(?:="(.+?)")?\](.+?)\[/quote\]#is', $post_txt, $matches);
     
    print_r($matches);
    Saul

  3. #3
    SitePoint Evangelist catweasel's Avatar
    Join Date
    Apr 2007
    Location
    Goldfields, VIC, Australia
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this page can help.

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2003
    Location
    P Town
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thnaks guys!!!

    php_daemon - That works perfict!!!!

    catweasel - That looks like it will be very useful


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
  •