Announcement

Collapse
No announcement yet.

preg_replace question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • preg_replace question

    I'm trying to replace strings like "00.jpg" with "00thumb.gif"

    Why is the statement:
    preg_replace( "/(\d+)\.\w{3,4}$/", "\\1thumb\.gif", $thumbimage );

    not working?
    Ryan "leadZERO" Sommers
    Gamer's Impact President
    [email protected]
    ICQ: 1019590
    AIM/MSN: leadZERO

    -= http://www.gamersimpact.com =-

  • #2
    Don't know the difference between ereg_replace and preg_replace, but I think you can leave the slashes alone, so
    Code:
    preg_replace( "^(\d+)\.\w{3,4}$", "\\1thumb\.gif", $thumbimage );
    Might work

    Comment


    • #3
      Zef, I didn't expect to see you hanging around here and helping out. How are things going with Yabb 2? Will it be PHP-based?

      Comment


      • #4
        $newfilename = preg_replace( "/(\\d+)\\.\\w{3,4}\$/", "\\1thumb\\.gif", $thumbimage );

        Comment


        • #5
          No, YaBB 2 will be perl based. But I like php more actually, I'm writing a new product using it.

          Comment


          • #6
            Yeah, I know what you mean. Perl is very powerful and versatile, but I never really could get used to the syntax.

            Comment


            • #7
              I know a fair bit of perl...

              Comment


              • #8
                Oh, well I know far more perl than php. But php has some nice features (like good mysql support), perl doesn't have (by default).

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X