Re: Mod_Substitute - Match the last occurrence of a string in the response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why are you attaching after the last meta tag - wouldn't it be easier just before the </head> tag or just after the <head> tag - you should have no other js in the header - except possibly an HTML 5 shim...


On 23/11/2016 08:08, Mayuresh wrote:

Any suggestions?


On Nov 22, 2016 11:32 AM, "Mayuresh" <mayuresh.kshirsagar@xxxxxxxxx> wrote:
Is there a way to make a 2 pass substitution? 1st one removing all the \n's and then using another one to substitute the string that I want?

On Tue, Nov 22, 2016 at 11:15 AM, Mayuresh <mayuresh.kshirsagar@xxxxxxxxx> wrote:
Hi Jason,

I tried it:

Substitute "s%(<meta [^>]*>).*?$%$1<script>window['start-time'] = new Date().getTime();window['app-key'] = \"xxx\";</script><script src=''></script>%i"


However it still replaces each line that the meta tag appears on.


Regards,

Mayuresh


On Tue, Nov 22, 2016 at 11:12 AM, Mayuresh <mayuresh.kshirsagar@xxxxxxxxx> wrote:
Hi Jason,

Each meta tag is appearing on a separate line. Will it work even then? Trying it out any ways.

Thanks,
Mayuresh

On Tue, Nov 22, 2016 at 10:41 AM, Jason Brooks <jason.brooks@xxxxxxxx> wrote:
Hello,

According to the Apache Glossary page, it’s all PCRE based.  So you should be able to use the “non-greedy” match.  So instead of .* which will match all instances, use .*?.  If you anchor it at the end of the string, something like (text you are matching against).*?$, then you can be certain of getting the last one.

—jason

Jason Brooks Systems Administrator
eROI Performance is Art.
 
m: 505 nw couch #300 w: eroi.com
t: 503.290.3105 f: 503.228.4249


fb: fb.com/eROI








On Nov 22, 2016, at 8:50 AM, Mayuresh <mayuresh.kshirsagar@xxxxxxxxx> wrote:

Hi,

How can I check for the last occurrence of a string in the response html and only replace the last occurrence of it?

I want to search for the last "meta" tag in the response and replace it with something.

How can I do this?

Thanks,
Mayuresh




--
-Mayuresh



--
-Mayuresh



--
-Mayuresh


-- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux