--- bobsawyerdotcom <[EMAIL PROTECTED]> wrote:
> Granted, my knowledge of regex is still pretty low (although it's > slowly improving), but I'm having a helluva time getting the following > to work: > > $buffer="<link>http://www.php.net</link>"; > > $foo = preg_replace('<link>([a-zA-Z0-9\/\.\:\?\=\&\;]*)</link>', > '<link><a href="ci.php?url=\1">\1</link>', $buffer); > > Basically, I need to prepend '<a href="ci.php?url=' onto the contents > of <link>, and append '">' onto the end of the contents of <link>. > I've struggled with this for too many hours now, so it's time to ask > the pros: What's wrong with this code? > > Thanks, > -Bob Without digging into the details of the regex, I see that your search regex is not surrounded by a character. The forwardslash (/) is common but I find that many times the pipe character (|) is helpful since it doesn't require as many backslash-forwardslash sequences. Try: $foo = preg_replace('|<link>([a-zA-Z0-9\/\.\:\?\=\&\;]*)</link>|', '<link><a href="ci.php?url=\1">\1</link>', $buffer); The ereg* functions don't use bounding characters but the preg* functions do. James _____ James D. Keeline http://www.Keeline.com http://www.Keeline.com/articles http://Stratemeyer.org http://www.Keeline.com/TSCollection http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc. Summer Semester Begins Jun 20 -- New Classes Start Every Few Weeks. Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
