Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #11174
| Newsgroups | microsoft.public.scripting.vbscript |
|---|---|
| Date | 2015-11-03 19:45 -0800 |
| Message-ID | <c62dc780-0b6a-44de-be21-7319105757ae@googlegroups.com> (permalink) |
| Subject | Regex Replace() with modified subexpressions? |
| From | Jim <google@zolx.com> |
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