Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15050

Re: Remove portion of string unless it contains variable

Newsgroups comp.lang.javascript
Subject Re: Remove portion of string unless it contains variable
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <9d0d2468-59b7-4b81-ab61-32875b019bb5@googlegroups.com> <d3dee133-3533-426d-a442-0b59d93262af@googlegroups.com>
Message-ID <XnsA0907AB5012C4eejj99@194.109.133.133> (permalink)
Date 2012-07-14 10:03 +0000

Show all headers | View raw


Jason C wrote on 14 jul 2012 in comp.lang.javascript:

> On Friday, July 13, 2012 7:27:09 PM UTC-4, Jason C wrote:
>> b = b.replace(/<img.*?src=["']*(.*?)["'}*.*?>/gi, '');
> 
> Type; that should have been a square after "', not a curly:
> 
> b = b.replace(/<img.*?src=["']*(.*?)["']*.*?>/gi, '');

Try this:

b = b.replace(/<img.*?src=(["'])[^\1]+\1[^>]*>/gi, '');


\1 is replaced by the actual match of (["'])

[^\1]+ quoted url should be not empty

[^>]*> matches anything till and including the next >

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Remove portion of string unless it contains variable Jason C <jwcarlton@gmail.com> - 2012-07-13 16:27 -0700
  Re: Remove portion of string unless it contains variable Jason C <jwcarlton@gmail.com> - 2012-07-13 17:51 -0700
    Re: Remove portion of string unless it contains variable "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-14 10:03 +0000
  Re: Remove portion of string unless it contains variable Mike Winter <usenet@michael-winter.me.invalid> - 2012-07-16 01:06 +0100

csiph-web