Question:
Mod_Rewrite Regex Replace Text?
Sisisisisi
2009-02-07 14:42:50 UTC
I've been trying to get my head around regular expressions and mod rewrite for hours and keep failing miserably :/

I'm trying to make a rewrite rule which replaces the letters 'abcd' (without quotations) for a '/' (without quotations). Anyone have ideas?
Three answers:
Andrei M
2009-02-09 07:48:43 UTC
Here you go:



RewriteRule (.*)abcd(.*) $1/$2



This rule works. I tested it on my server.
2009-02-07 14:56:05 UTC
I'm not sure if this will help you or not but this is how I'd do it in Perl. I believe that regexes work fairly much the same regardless of language.



use strict;



my $x = '/';



$x =~ s!/!abcd!;



print $x;



I don't know if you can replace your regex delimiters in Apache or not, so you may have to escape your / so that it doesn't mess it up.



Hope that helps!
?
2016-12-24 22:42:07 UTC
from time to time hitting the Pause/injury button motives textual content cloth to get replaced. yet then theres the Insert button it rather is next to the backspace that does the comparable factor so the respond is the two certainly one of those.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...