Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output text based on regular expression

Status
Not open for further replies.

gacaccia

Technical User
May 15, 2002
258
US
does vbscript provide any tools for outputting text based on a regular expression? i basically want to use regular expressions as text generators. for example, if i have a regular expression that indicates a max length of 20 alpha characters, then it would output a random string of 0 to 20 alpha characters. i'm sure i can manually code my own function to parse a regular expression, but that would be a ton of work. any thoughts? anyone done this before?

thanks,

glenn
 
yeah, i had been to that link before and didn't see anything. maybe that's the answer, no regexp tools available to output text. did you see something there that specifically dealt with my question?
 
VBScript can make use of Regular Expression which you can use to test a string you would need to generate on your own.

Code:
Option Explicit

Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "\w{20}"
RegEx.Global = True
RegEx.IgnoreCase = True

WScript.Echo "Is 20 characters long?  " & CStr(RegEx.Test("123"))
WScript.Echo "Is 20 characters long?  " & CStr(RegEx.Test("ABCdefHIJk0123456789"))

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
right, but if i generate my own string, i already know it's 20 characters long so there's no need to test it. ultimately, what i want is to be able to code something like

Code:
dim outputString
outputString = regExpGeneratedString("\w{20}")

again, i could create my own function to parse a regular expression, but i was hoping there was already some support for doing that.
 
Sorry, but you're SOL.


--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top