RegEx Problem in .NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Perhaps someone here can help me out...

RegEx: "^.*\d{5}(-\d{4})?.*$"
Intended Purpose: To strip out the City/State/ZipCode line from a signature.
Sample Text:

Joe Jackson
131 W. 5th Street
New York, NY 10023

RegEx Should Return: "New York, NY 10023"

1) This RegEx works correctly in Excel using "Microsoft VBScript Regular
Expressions 5.5" object library
2) This RegEx works correctly with web-based .NET processor on
http://www.regexlib.com/RETester.aspx
3) This RegEx DOES NOT WORK in .NET v1.1 (well, at least not for me!)
4) I found the article "FIX: The Regex class and the Match class may not
correctly find matches for a regular expression" on Microsoft Support site
(http://support.microsoft.com/default.aspx?scid=kb;en-us;822923), however the
versions of the files that they say create the fix are OLDER than the ones I
have, so perhaps this is a fix for .NET v1.0. ???
 
BigAl said:
Intended Purpose: To strip out the City/State/ZipCode line from a signature.
Sample Text:

Joe Jackson
131 W. 5th Street
New York, NY 10023

RegEx Should Return: "New York, NY 10023"

Regex regex = new Regex(@"(^.+\d{5}$)",
(RegexOptions) 0);
 
Back
Top