• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Click "RG3" at the very bottom-left of this page to change it. To dismiss this notice, click the X --->

Tech - seeking regexp to fix broken links on RedGuides (1 Viewer)

Redbot

🖥️💖
Moderator
Joined
Oct 15, 2004
RedCents
64,156¢
The problem
This link works:
https://www.redguides.com/forums/th...-Puller-Ready-(using-conditions-AND-mq2melee)
This link doesn't:
https://www.redguides.com/forums/th...-Puller-Ready-(using-conditions-AND-mq2melee)

Why?
Our new software dislikes special characters in the URL, such as !_(), while our old software loved them. I wrote a little nginx directive looking for redguides.com/forums/ links to remove special characters when forwarding to the new redguides.com/community. HOWEVER, when we switched over to the new forums, I foolishly did a mysql replace on all the lines containing https://www.redguides.com/forums/ to https://www.redguides.com/community, so now we have URLs with special characters that my nginx directive can't see or fix.

The easiest fix in my opinion is switching the old URLs from "community" back to "forums".

How?
This is where I'm stuck! I need a regex to select "community" in links like this:
https://www.redguides.com/forums/th...-Puller-Ready-(using-conditions-AND-mq2melee)

But not links like this:
https://www.redguides.com/community...er-ready-using-conditions-and-mq2melee.60941/

Anyone up for the challenge? please pm meeee
 

Redbot

🖥️💖
Moderator
Joined
Oct 15, 2004
RedCents
64,156¢
Here's what would have worked,

(redguides\.com\/)community\/threads(\/.*[\(\)\_\!\*].*)$
and the replace,
$1forums/threads$2

However, our database doesn't fully support regex.

Alynel suggests we dump the DB, use sed, import the DB. One issue: how do I regex replace with sed?
 
Last edited:

Redbot

🖥️💖
Moderator
Joined
Oct 15, 2004
RedCents
64,156¢
no luck :\

sed -e "s/(redguides\.com\/)community\/threads(\/.*[\(\)\_\!\*].*)$/$1forums\/threads$2/g" test.txt > fix.txt

Results in no changes. It's odd because the regex seems to work here:
https://regex101.com/r/eA7Ifr/2

edit: seems to be tripping up on the capture groups, time to read some tutorials

edit: got it! huge thanks to @alynel & @dannuic
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top