Thank you Marc, that did the trick ;?)

On Sunday, November 19, 2017 at 7:54:41 PM UTC, Marc Simpson wrote:
>
> A couple of things: 
>
> - // quoting shouldn't be further quoted (use /foo/ rather than '/foo/') 
> - Captures are referenced with $, not \ (use $1 rather than \1) 
>
> As for your requirement, this might be a simpler approach: 
>
>   str.replace(/_([^\d]|$)/g, '%20$1') 
>
> i.e., replace any underscore followed by a non-digit (or occurring at 
> the end of string) with %20. 
>
> On Sun, Nov 19, 2017 at 11:04 AM, jgill <[email protected] 
> <javascript:>> wrote: 
> > I am trying to replace all instances of an underscore with %20 except 
> when 
> > the underscore if followed by a digit using Javascript. The replacement 
> > works fine in BBEdit 
> > 
> > var str='Test_One_Two_Three_101117a.JPG'; 
> > var pattern='/(.*?)_(\d\d\d\d\d\d\w.JPG)/'; 
> > var r=str.replace(pattern,'\1%20\2'); 
> > document.write(r); 
> > 
> > 
> > What is wrong with this? 
> > 
> > -- 
> > This is the BBEdit Talk public discussion group. If you have a 
> > feature request or would like to report a problem, please email 
> > "[email protected] <javascript:>" rather than posting to the group. 
> > Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "BBEdit Talk" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/bbedit. 
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to