Link to home
Start Free TrialLog in
Avatar of parveenmehta
parveenmehta

asked on

How do i search using Regex?

Experts
I have a long string comming in from database where i am telling the user that your registration expires on a particular date and so on.
What i want to do is that i want to search for this date in that text and i want to replace it with another date that also comes from my database.
I want to use regex here to check whether there is first of all anything like a date in text and second it is a valid date and then third if the first 2 are true replacing with the expiration date from another object.
I would appreciate your opinion about this.
Thanks
Avatar of ozo
ozo
Flag of United States of America image

Are the dates in the file in any particular format/language?
Are there some sets of dates that are not consider valid for your purposes?
If so, what should be done with them?
Are there things other than dates in the file?
Avatar of parveenmehta
parveenmehta

ASKER

Yes the date formate is mm/dd/yyyy.As long as there is a valid date i should be able to take that and replace  that with the available expiration date.Yes there is a text "Your certification expires on 05/01/2006".So i want to be able to replace the expiration date at the end.
This is what i have done so far.But the default date that is comming in the textbox is not getting replaced.
string dt=dsexpdt.Tables[0].Rows[0]["ExpirationDate"].ToString();
txtcell5.InnerHtml=Regex.Replace(txtcell5.InnerHtml,@"(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d",dt);
Can anyone please suggest ?
Thanks                  
Might it be easier to search for "Your certification expires on" ?
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
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