Page 1 of 1
Writing a regex..
Posted: Tue Jun 28, 2022 6:09 am
by harryray2
I'm using an addon for Firefox called redirector.
It automatically redirects to user defined urls on certain pages. It accepts both wildcards and regex.
One of the wildcard redirects I use is:
Include pattern:
https://voe*.*/*
Redirect to:
https://9xbuddy.org/process?url=https://voe.sx/$3
I'm trying to write a regex equivalent but I can't quite seem to get it right.
Any ideas please?
Re: Writing a regex..
Posted: Tue Jun 28, 2022 6:12 am
by void
For wildcards to regex, please try:
replacing * with .*
and replacing . with \.
https://voe.*\..*/.*
Looks like they support group captures too, so maybe something like:
https://voe.*\..*/(.*)
and then use \1 (or maybe they use $1?) in "Redirect to" to recall the text matched inside ()
Re: Writing a regex..
Posted: Tue Jun 28, 2022 8:36 am
by harryray2
Thanks so much, I think I've got it...
Include pattern:
https://voe.*\..*/(.*)
Redirect to:
https://9xbuddy.org/process?url=https://voe.sx/$1?
I'm afraid that regex makes my head spin :0)
Re: Writing a regex..
Posted: Tue Jun 28, 2022 12:56 pm
by raccoon
If it helps, here's the translation from the globbing wildcards you're already familiar with to their regex equivalent.
Code: Select all
glob regex
wildchar: ? .
wildcard: * .*
period: . \.
stardotstar: *.* .*\..*
stardotexe: *.exe .*\.exe
backslash: \ \\
foreslash: / \/
colonbacksl: c:\ c:\\
slashslash: ftp:// ftp:\/\/
You may also have to escape your slashes with backslashes in your filters for it to work.
Re: Writing a regex..
Posted: Tue Jun 28, 2022 7:42 pm
by harryray2
Thanks a lot, that should help... The problem I was having was capturingthe characters at the end.
eg:
https://voeun-block.net/qiqqffsxdtu5
The wildcard part was relatively easy to work out but I couldn't seem to get the
qiqqffsxdtu5 part to appear, what I was getting was
https://voe.sx/$1?, instead of
https://voe.sx/qiqqffsxdtu5
The (.*) as suggested by void solved the problem.