Anthony
Mon Jan 29 10:26:36 CST 2007
"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:eNQrsw7QHHA.5032@TK2MSFTNGP03.phx.gbl...
> Replied to [Big D]s message :
> > I use a object that returns a list of computernames to perform a
function.
> > Since we have done a good job with our computer naming conventions I am
> > using this object but want to replace just part of the computername to
query
> > the other device on network.
> >
> >
> > For example,
> >
> > I get a list of machines named:
> >
> > DC1RES000101
> > DC2RES000102
> > DC3RES000103
> >
> > As I get each machine using a For Each statement...I need to replace the
> > 'RES' with a 'SCS'
> >
> > DC1SCS000101
> > DC2SCS000102
> > DC3SCS000103
> >
> >
> > How can I do a replace of the three letters in middle of computerName.
> >
> >
>
> Use Replace method :
> Replace(string,replaceWord,replaceWith)
>
> for example:
> replace(computerNames,"RES","SCS")
>
That'll work well if there are no other occurances of RES that don't need
replacing.
>
> OR Use RegExp.Replace :
>
> set regXp = New RegExp
> regXp.Pattern = "\w{3}RES\w{6}"
>
>
> AND put the folowing in loop :
> regXp.Replace(computerName,"SCS")
>
A loop is unnecessary howevet it will replace the whole computer name not
just the RES in the name.
set rgx = New RegExp
rgx.Pattern = "(\w{3})RES(?=\w{6})"
rgx.Global = True
computerNames = rgx.Replace(computerNames, "$1SCS")
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia -
http://en.wikipedia.org
> Snip your long urls -
http://snipurl.com/
> -------------