Hello!
On Fri, May 3, 2013 at 6:03 PM, vocaltrancea wrote:
> Hello I'm trying to replace an email on a page the format is like this:
>
> "someemail@gmail.com (logout)"
>
> How can I replace that text with something else?
>
What is the HTML source for that piece? ngx_replace_filter only works
on the HTML source level for web pages. It never tries to understand
or parse the HTML stuffs.
> I tried doing this:
>
> replace_filter '\S+@\S+\.\S+\s+\w(logout)' '[email hidden]' g;
>
One obvious mistake in your regex is the use of unescaped parentheses
because parenthese are special meta characters for submatch capturing.
I think you probably mean just this
replace_filter
'[-.\w]+@([-.\w]+\.)+(?:com|us|cn|org|net|name|info)' '[email hidden]'
g;
This regex for email addresses here is not all-inclusive. If you
really want to include the " (logout)" context in your regex, just
ensure you include its corresponding HTML source snippet in your regex
(and also ensure it is properly escaped according to the regex
syntax).
Best regards,
-agentzh