X-Received: by 10.107.17.8 with SMTP id z8mr583739ioi.12.1446608723657; Tue, 03 Nov 2015 19:45:23 -0800 (PST) X-Received: by 10.182.227.200 with SMTP id sc8mr167787obc.10.1446608723602; Tue, 03 Nov 2015 19:45:23 -0800 (PST) Path: csiph.com!xmission!news.glorb.com!i2no3804384igv.0!news-out.google.com!fs1ni7423igb.0!nntp.google.com!i2no3804376igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: microsoft.public.scripting.vbscript Date: Tue, 3 Nov 2015 19:45:23 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.134.193.225; posting-account=N0e9tgoAAAA18P51Kg5cUembaFJwY8ta NNTP-Posting-Host: 50.134.193.225 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Regex Replace() with modified subexpressions? From: Jim Injection-Date: Wed, 04 Nov 2015 03:45:23 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com microsoft.public.scripting.vbscript:11174 I use VBScripts' regex Replace() method a lot to modify strings. It's great= for rearranging and removing parts of a string, but I haven't yet found a = way, if it's possible, to modify subexpressions found in a match when using= Replace(). For example, in the following: Set re =3D New RegExp re.IgnoreCase =3D True re.Pattern =3D "^.*\-\s*(.*)$" s =3D "This is a Test - Keep only this part" WScript.Echo s s =3D re.Replace(s, "$1") WScript.Echo s I often want to do something like capitalize the matched $1 subexpression. = It can be done with Execute() and some more code, but would be convenient i= f I could figure out how to form the second argument to Replace() so it cou= ld be done in just a line of code.