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


Groups > microsoft.public.scripting.vbscript > #11177

Re: Regex Replace() with modified subexpressions?

From "Steve" <cerberus40+usenet@gmail.com>
Newsgroups microsoft.public.scripting.vbscript
Subject Re: Regex Replace() with modified subexpressions?
Date 2015-11-04 06:52 -0500
Organization A noiseless patient Spider
Message-ID <n1crh7$130$1@dont-email.me> (permalink)
References <c62dc780-0b6a-44de-be21-7319105757ae@googlegroups.com>

Show all headers | View raw


"Jim" <google@zolx.com> wrote in message 
news:c62dc780-0b6a-44de-be21-7319105757ae@googlegroups.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().

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.

MS added this to VBS with version 5.5 but only documented it in one 
place:

https://msdn.microsoft.com/en-us/library/ms974619.aspx?f=255&MSPPError=-2147217396

The page is mostly about JScript but there is a "What About VBScript?" 
section at the end which documents what you want to do.

-- 
Steve

In theory, there is no difference between theory and practice; in
practice, there is. -Chuck Reid

Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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