View Single Post
  #3 (permalink)  
Old November 5th, 2003, 03:55 PM
nikolai nikolai is offline
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Rich,

I'd recommend reading through PHP's manual pages:
  http://www.php.net/pcre

Check out their "pattern syntax" and "pattern modifiers" page. Also, search for 'perl regular expression tutorial' on google; there's lots of hits.


I don't think for your case you need to use create_function(); the problem with that approach is that you create an unnamed function EVERY time you get to the point in execution. I don't think it causes a huge amount of excess overhead, but it's there nonetheless.


I don't have the time to play with your original patterns, but I suspect a couple reasons your patterns are failing:

1) You're using a dollar to access your back references. Perl-compatible regexes in PHP use a backslash and a number between 0 and 99 to access a back reference.

2) Your 2nd pattern isn't a valid string:
  "(^)"<a href=\"http$3://$4$5\"target=\"_blank\">$2$4$5</a>"

The 4th character of your pattern string is a double-quote character, which ends the string and should cause a parse error.

Good luck, and let me know if any more problems come up.





Take care,

Nik
http://www.bigaction.org/
Reply With Quote