Patricia
Mon Sep 18 12:41:43 CDT 2006
This looks like I can really make use of it... is there any way to
manipulate this so the replacement string (complex) would be pulled from
another document? For example... trying to automate report-writing. I will
have a text-based or excel-based inventory (server hardware/software,
configuration info, etc) and need to pull it into a formal document. Each
customer will have a unique environment with not every customer having the
same sub-set of products deployed, and I would dearly love to write a tool
or template that updates certain fields in a Word doc with the info in the
inventory dump, when that particular item is present.
Any suggestions?
"JTW" <Newsgroup@Dx21.com> wrote in message
news:ere2sPC2GHA.4264@TK2MSFTNGP05.phx.gbl...
> Here are two simple demos on how to use (VBS) Regular Expressions to
> find and replace text (the "simple" for your provided string, the
> "complex" for longer strings):
>
> Set objRE = New RegExp
> objRE.Global = True
> objRE.IgnoreCase = True
>
> 'SIMPLE
> objRE.Pattern = "(/| )"
>
> str1 = "100/25 blocks"
> str1b = objRE.Replace(str1,",")
> WScript.Echo str1b
>
> 'COMPLEX
> str1 = "100/10 hits in one part of the document, "
> str1 = str1 & "then 100/25 blocks then more " & VbCrLf
> str1 = str1 & "in another / part of the document."
>
> objRE.Pattern = "/([\w]+) "
> Set colMatches = objRE.Execute(str1)
> For Each objMatch In colMatches
> objRE.Pattern = "/" & objMatch.SubMatches(0) & " "
> str1 = objRE.Replace(str1,"," & objMatch.SubMatches(0) & ",")
> Next
>
> WScript.Echo str1
>
>
>
>
> --
> Jase T. Wolfe
> Dx21, LLC
>
http://www.Dx21.com
>
>
> Epoh Rio wrote:
>
>> Hello all:
>>
>> I would like to find all occurances of a "/" in a document and
>> replace it with a "," and then search for the next space (in that
>> line) and replace it with a ","
>>
>> Example Text
>>
>> 100/10 hits
>> 100/25 blocks
>>
>> 100,10,hits
>> 100,25,blocks