This forum is for programmers who have questions about the source code.
-
Herewiss
- Posts: 3
- Joined: Mon Mar 10, 2008 8:58 am
- Location: Bangor, ME
-
Contact:
Post
by Herewiss » Mon Mar 10, 2008 10:47 am
When I try to enter a phone number as "111-222-3333", it breaks, since the first thing it does is add a leading "(". "(111-" doesn't match any of the existing regexes.
This patch seems to work on my machine:
Code: Select all
Index: ClassesShared.cs
===================================================================
--- ClassesShared.cs (revision 1380)
+++ ClassesShared.cs (working copy)
@@ -332,7 +332,11 @@
if(Regex.IsMatch(phoneNum,@"^\(\d\d\d\d$")){
return( phoneNum.Substring(0,4)+")"+phoneNum.Substring(4));
}
- if(Regex.IsMatch(phoneNum,@"^1\(\d\d\d\d$")){
+ if (Regex.IsMatch(phoneNum, @"^\(\d\d\d\-$"))
+ {
+ return (phoneNum.Substring(0, 4) + ")");
+ }
+ if(Regex.IsMatch(phoneNum,@"^1\(\d\d\d\d$")){
return( phoneNum.Substring(0,5)+")"+phoneNum.Substring(5));
}
if(Regex.IsMatch(phoneNum,@"^\(\d\d\d\)\d\d\d\d$")){
-
jordansparks
- Site Admin
- Posts: 5770
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
-
Contact:
Post
by jordansparks » Mon Mar 10, 2008 6:18 pm
The formatting is designed to only happen as you type. It doesn't "break". It just annoyingly tries to reformat it for you. 111 is not a valid area code, so it's behaving exactly like it should. Unless you are saying it actually crashes.
-
Herewiss
- Posts: 3
- Joined: Mon Mar 10, 2008 8:58 am
- Location: Bangor, ME
-
Contact:
Post
by Herewiss » Tue Mar 11, 2008 5:47 am
Well, "207-555-1212" would do the same thing. If you type it like that, you're left with "(207-555-1212" -- my patch changes it to "(207)555-1212".
Garrett Fitzgerald
Penobscot Community Health Care
Bangor, ME