Regular Expression Question...

G

Guest

I am not sure if this is the correct forum to post this question so I thought
I would start here.

Is there any way to generate a new string (conditionally) based on an input
string and a regular expression?. Is there any method (such as Replace) of
the RegEx object that will do this?

For example...

string s1;
string s2;
string s3;

s1 = "^(?<dd>\\d{2, 2})$";
s2 = "YEAR : ${dd}";
s3 = RegEx.Replace("06", s1, s2");

The variable s3 now has the value "YEAR : 06". I would somehow like the
variable s3 to have the value "YEAR : 2006" (or the value "YEAR : 1980" if
the value of the first parameter was "80") using only the code above. The
criteria for prefixing the input with either "19" or "20" would depend on
whether he input was less than or equal to 60.

Thank you,

Jason Richmeier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top