Anybody out there good with Regular Expressions / REGEX?

AdvToorer

Member
Joined
Jun 25, 2012
Messages
99
Location
Denver, CO - USA
My experience with REGEX is in Python, PERL, and grep (bash). In Python and PERL use I typically create a regex to perform the match and "capture" a specific portion of the string (like "300" in your example), then create the replacement string using the captured string concatenated with whatever new string.
Based on your example, I would capture the topic value using regex:
/topic=(\d+)\.
Then create new string using "http://www.yamahasupertenere.com/index.php?threads/" + $capturestring + "/"
How you perform the concatenation will be dependent on the forum software.

I like regex101.com for testing regular expressions as it gives a great explanation how it's decoding the string and applying the regex match. Click here for an example I created.
 
Last edited:

Venture

Administrator
Staff member
Founder
Joined
Feb 26, 2010
Messages
2,110
Ah, need the regex to rewrite older URL (such as Google search results) to the new forum URL?
Yes, but I need to do it using Nginx rewrite, which is proving problematic. I can't seem to get Nginx to process the rewrites, and that is what is holding things up. Once I get at least a simple rewrite working I can focus on the specific ones I need for posts, topics, users, and boards.
 
Top