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
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
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.
ASKER
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]["Expira tionDate"] .ToString( );
txtcell5.InnerHtml=Regex.R eplace(txt cell5.Inne rHtml,@"(0 [1-9]|1[01 2])[- /.](0[1-9]|[12][0-9]|3[01] )[- /.](19|20)\d\d",dt);
Can anyone please suggest ?
Thanks
string dt=dsexpdt.Tables[0].Rows[
txtcell5.InnerHtml=Regex.R
Can anyone please suggest ?
Thanks
Might it be easier to search for "Your certification expires on" ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?