Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hi
How do I generate a string from a regular expression? RedGate are able to do this so I know it's posible just not sure how.

Basically I want to be able to provide

\w{10}

and I will get a 10 character string back

or

\d{13}

and get a 13 digit string back.

Thanks in advance
Posted
Updated 23-Aug-11 22:17pm
v2
Comments
Prerak Patel 24-Aug-11 2:54am    
Not clear what you mean by - generate a string form regular expression.
Gordon Beeming 24-Aug-11 4:18am    
please see my updated question

1 solution

Regex.Matches method?

Update: This is not a correct requirement. Consider you have a regular expression "\w". Now there are more than a million number of strings that match to this expression. If not the entire string, then parts of it will.
 
Share this answer
 
v2
Comments
Gordon Beeming 24-Aug-11 4:18am    
I'm not looking to match an expression in text but to generate the text off a regular expression
lukeer 24-Aug-11 4:55am    
The resulting string should be totally random within the limits the regex provides?
Gordon Beeming 25-Aug-11 3:19am    
please explain more, when I type Regex.Matches it asks for an input which isn't really what I need here
dan!sh 25-Aug-11 4:11am    
Updated the reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900