Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11174
| 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 | <c62dc780-0b6a-44de-be21-7319105757ae@googlegroups.com> (permalink) |
| Subject | Regex Replace() with modified subexpressions? |
| From | Jim <google@zolx.com> |
| 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 |
Show key headers only | View raw
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 = New RegExp re.IgnoreCase = True re.Pattern = "^.*\-\s*(.*)$" s = "This is a Test - Keep only this part" WScript.Echo s s = 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 if I could figure out how to form the second argument to Replace() so it could be done in just a line of code.
Back to microsoft.public.scripting.vbscript | Previous | Next — Next in thread | Find similar
Regex Replace() with modified subexpressions? Jim <google@zolx.com> - 2015-11-03 19:45 -0800
Re: Regex Replace() with modified subexpressions? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-11-04 09:32 +0100
Re: Regex Replace() with modified subexpressions? "Steve" <cerberus40+usenet@gmail.com> - 2015-11-04 06:52 -0500
Re: Regex Replace() with modified subexpressions? Jim <google@zolx.com> - 2015-11-05 01:09 -0800
csiph-web