Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 28EEE200BC8 for ; Wed, 23 Nov 2016 10:25:30 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 2419C160AFD; Wed, 23 Nov 2016 09:25:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EF000160AFA for ; Wed, 23 Nov 2016 10:25:28 +0100 (CET) Received: (qmail 87204 invoked by uid 500); 23 Nov 2016 09:25:27 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 87193 invoked by uid 99); 23 Nov 2016 09:25:27 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2016 09:25:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 08729C1D00 for ; Wed, 23 Nov 2016 09:25:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.289 X-Spam-Level: X-Spam-Status: No, score=-3.289 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-2.999, SPF_PASS=-0.001, T_HK_NAME_DR=0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id fgudhMrL9wlb for ; Wed, 23 Nov 2016 09:25:25 +0000 (UTC) Received: from smtp.sanger.ac.uk (smtp.sanger.ac.uk [193.62.202.243]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id B07515F39A for ; Wed, 23 Nov 2016 09:25:24 +0000 (UTC) Received: from sa4500.internal.sanger.ac.uk ([172.22.1.22] helo=mpdomain) by intmail3b.internal.sanger.ac.uk with esmtp (Exim 4.80.1) (envelope-from ) id 1c9Tnu-0002YF-PB for users@httpd.apache.org; Wed, 23 Nov 2016 09:25:23 +0000 To: users@httpd.apache.org References: <2F465704-F9E8-402F-B469-4B504A1788AB@eroi.com> From: Dr James Smith Message-ID: <31068c23-f2d3-84dd-6f1d-96f3f468d025@sanger.ac.uk> Date: Wed, 23 Nov 2016 09:25:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------57DE0863246844457F164BA4" X-Message-Source: sa4500.internal.sanger.ac.uk Subject: Re: [users@httpd] Mod_Substitute - Match the last occurrence of a string in the response archived-at: Wed, 23 Nov 2016 09:25:30 -0000 --------------57DE0863246844457F164BA4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Why are you attaching after the last meta tag - wouldn't it be easier just before the tag or just after the 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" > 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 > > wrote: > > Hi Jason, > > I tried it: > > Substitute "s%( [^>]*>).*?$%$1%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 > > 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 > > 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 >> > > 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. --------------57DE0863246844457F164BA4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

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@gmail.com> 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@gmail.com> wrote:
Hi Jason,

I tried it:

Substitute "s%(<meta [^>]*>).*?$%$1<script>window['start-time'] = new Date().getTime();window['app-key'] = \"xxx\";</script><script src='/epicdev.js'></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@gmail.com> 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@eroi.com> 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@gmail.com> 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.
--------------57DE0863246844457F164BA4--