Using Regular Expressions in .NET Framework 2.0

  • Thread starter Thread starter Brian Roisentul
  • Start date Start date
B

Brian Roisentul

Hello,

I'm developing a windows application where I use regular expressions.

In first place, I did it in c#(visual studio 2003) and now I'm
migrating it to visual studio 2005.

The problem here is that a regular expression doesn't match an xml
string in visual studio 2005, but in visual studio 2003 does. Is the
same code in both and the same xml string.

Can anybody helps me?

Thanks,

Brian
 
Brian said:
Hello,

I'm developing a windows application where I use regular expressions.

In first place, I did it in c#(visual studio 2003) and now I'm
migrating it to visual studio 2005.

The problem here is that a regular expression doesn't match an xml
string in visual studio 2005, but in visual studio 2003 does. Is the
same code in both and the same xml string.

Can anybody helps me?

Thanks,

Brian
Provide the regular expression you are using and the XML snippet you are
having problems with
 
Hello,

Thanks for your quick response, here is the regular expression I'm
having problems with:

(?<date>\d{4}-\d{2}-\d{2})(?<time>T\d{2}:\d{2}:\d{2}.\d{7}-)(?<hour>\d{2})(?<last>:\d{2})

The string that must match would be something like
"2006-04-06T14:03:33-03:00".

If I try to parse only that string(without the rest of the xml) it
works, but it doesn't if I try with the whole xml string.

NOTE: It does work in Visual Studio 2003, but not in 2005.

Thanks,

Brian
 
Hey, I'm sorry I didn't show you the xml string.

Here it is:

"<NewDataSet><Table><tp_ID>1</tp_ID><tp_ListId>e86df149-dcae-4344-83e1-ef9be5bb99cb</tp_ListId><tp_SiteId>b98533db-58a3-48c2-af6e-62241e4afa26</tp_SiteId><tp_Version>7</tp_Version><tp_Author>1</tp_Author><tp_Editor>1</tp_Editor><tp_Modified>2006-04-06T14:03:33-03:00</tp_Modified><tp_Created>2006-03-21T17:27:52-03:00</tp_Created><tp_HasAttachment>false</tp_HasAttachment><tp_ModerationStatus>0</tp_ModerationStatus><tp_IsCurrent>true</tp_IsCurrent><tp_ItemOrder>100</tp_ItemOrder><tp_GUID>64686e35-f5d2-4c06-b2ac-f4188afd122e</tp_GUID><tp_Size>26</tp_Size><nvarchar1>All</nvarchar1><float1>1</float1></Table></NewDataSet>"

The fields that must match are "<tp_Modified>" and "<tp_Created>".

Thanks,

Brian
 
Brian said:
Hey, I'm sorry I didn't show you the xml string.

Here it is:

"<NewDataSet><Table><tp_ID>1</tp_ID><tp_ListId>e86df149-dcae-4344-83e1-ef9be5bb99cb</tp_ListId><tp_SiteId>b98533db-58a3-48c2-af6e-62241e4afa26</tp_SiteId><tp_Version>7</tp_Version><tp_Author>1</tp_Author><tp_Editor>1</tp_Editor><tp_Modified>2006-04-06T14:03:33-03:00</tp_Modified><tp_Created>2006-03-21T17:27:52-03:00</tp_Created><tp_HasAttachment>false</tp_HasAttachment><tp_ModerationStatus>0</tp_ModerationStatus><tp_IsCurrent>true</tp_IsCurrent><tp_ItemOrder>100</tp_ItemOrder><tp_GUID>64686e35-f5d2-4c06-b2ac-f4188afd122e</tp_GUID><tp_Size>26</tp_Size><nvarchar1>All</nvarchar1><float1>1</float1></Table></NewDataSet>"

The fields that must match are "<tp_Modified>" and "<tp_Created>".

Thanks,

Brian
I think that I would start with an anchor, end with an anchor, don't use
Microsoft extras and express the Regular Expression as
/>(\d{4}-\d{2}-\d{2})?*?</
If your xml is well formed that should do it.
 
Back
Top