SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: ereg_replace

  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Santa Campaign HQ
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    i have the code:
    PHP Code:
    $text ereg_replace(
      
    "\[T=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
      
    "([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[/T]",
      
    "<table width="50%" border="6" cellspacing="0" cellpadding="0" bordercolorlight="#000066" bordercolordark="#000066" align="center"><tr bgcolor="#000066"><td><div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="6" color="#FFFFFF"><b>\\1</b></font><font face="Verdana, Arial, Helvetica, sans-serif" size="6"></font></div></td></tr><tr><td><blockquote><div align="left"><font face="Verdana, Arial, Helvetica, sans-serif">//2</font></div></blockquote></td></tr></table>", $text); 
    andit dosen't work...anyideas/

    by the way, i'm not an expert with ereg replace, and this coide was adapted from kevins php tutorial.
    A vote for LemonZone is a vote for more presents!!
    Campaigning to become the next santa since 1996!

  2. #2
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Santa Campaign HQ
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WELL, it dosent give me a parse error any more, but it just says [T=Title text]TTTTTTTTTTTTTTTTTesingtthe blok quote function [/T]
    Last edited by LemonZone; May 7, 2001 at 01:46.
    A vote for LemonZone is a vote for more presents!!
    Campaigning to become the next santa since 1996!

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you escaping all the quotes?

    What are you trying to accomplish with it?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Santa Campaign HQ
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I Changed the code so that it is ' instead of " wherever there is one

    i'm trying to create a table that can contain a quote

    something like this

    +---------------------+
    | USER TEXT HERE!!!!! |
    +---------------------+
    | Then, in here some |
    | Form of user |
    | specified text |
    | |
    +---------------------+

    i know its not very clear, but i want it to have the code:

    [T=Title of Table]Text inside the table, for instance a quote[/T]

    Thanks,
    Alex
    A vote for LemonZone is a vote for more presents!!
    Campaigning to become the next santa since 1996!

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so you're parsing

    [T=Title of Table]Text inside the table, for instance a quote[/T]

    and want to replace it with your table code?


    Well your problem is with the []'s

    []'s are reserved for use in regular expressions.

    you need to escape them.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Santa Campaign HQ
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    //blockquote thingys
    $text ereg_replace(
      
    "\[T=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
      
    "([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[/T]",
      
    "<table width='50%' border='6' cellspacing='0' cellpadding='0' bordercolorlight='#000066' bordercolordark='#000066' align='center'>tr bgcolor='#000066'><td><div align='center'><font face='Verdana, Arial, Helvetica, sans-serif' size='6' color='#FFFFFF'><b>\\2</b></font><font face='Verdana, Arial, Helvetica, sans-serif' size='6'></font></div></td></tr><tr><td><blockquote><div align='left'><font face='Verdana, Arial, Helvetica, sans-serif'>//1</font></div></blockquote></td></tr></table>",$text); 
    Still dosent work.
    A vote for LemonZone is a vote for more presents!!
    Campaigning to become the next santa since 1996!

  7. #7
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't look escaped to me.

    need to escape them in the expression too.

    you can also do this instead.

    do a str_replace on your string and replace them with codes

    [ = 99Z

    ] = 99Q

    etc

    then change your regular expression accordingly.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  8. #8
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Santa Campaign HQ
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is getting on my nerves...somehwere between editplus and sitepoint, they dissapeared

    but they are there....and it dosen't work
    A vote for LemonZone is a vote for more presents!!
    Campaigning to become the next santa since 1996!

  9. #9
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you escape them in the text you are parsing too?

    but honestly this is supposed to work but when I had to do this same thing I couldn't get it either so I used the str_replace method.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  10. #10
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey LemonZone, you need

    1) Escape the opening brackets,
    Code:
    "\[T=([-_./a-zA-Z0-9!&%#?,'=:~]+)]([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[/T]"
    2) Include the space in your searching pattern, ie,
    Code:
    ([ -_./a-zA-Z0-9!&%#?,'=:~]+)
    (Note the blank space after the [ )

    Hope this works for you (works for me )


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
  •