Link to home
Start Free TrialLog in
Avatar of unicorn_rm
unicorn_rm

asked on

How to generate a string from a Regular Expression?

I have a regular expression using which i need to generate its corresponding string token..
Avatar of Ravi Kalla
Ravi Kalla
Flag of India image

A regular expression can generate infinate strings. So, a single string token can't be generated to it. Do you want to find the strings that satisfies the Regular Expression from a list of strings?
Mention you requirement in detail.
 
Perhaps you mean to show the string representation of a regular expression in memory? The following code snippet shows how to print the internal regular expression as it was passed into the regex  constructor. It prints the following:

[hH]ello\s+[wW]orld$

// output the internal regular expression
Regex re = new Regex(@"[hH]ello\s+[wW]orld$");
Debug.WriteLine(re.ToString());

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of tazmaster
tazmaster
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
what kind of correspondence are you talking about?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i wasn't making a serious suggestion... i was attempting to demonstrate the futility of attempting it.
;-)
then I think we made the right point together :D
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nice one, I particularly like the Explain module (I don't really see the point in Genex... but hey, if that's the request ;-)

I think these answers are very valuable and all that for 50p ;-) ....but the q. has been abandoned since the start...
This question received ample coverage, multiple experts come to the same conclusion: "cannot be done" unless you have infinite time/space.

http:#24744034 (abel) shows how to tell the string repres. of a regex
http:#24887998 (tazmaster) explains the futility of getting matching strings
http:#24895361 (abel) elaborates on that
http:#24902652 (ozo) giving another angle with Explain and GenEx

Suggestion: equal split between http:#24887998 (tazmaster), http:#24895361 (abel) and http:#24902652 (ozo).