Regular Expression question (cont.)

# Thread: Regular Expression question (cont.)

1. Senior Member
Join Date
Dec 1969
Posts
122

## Regular Expression question (cont.)

Thanks for all the replies yesterday. I want to pick up the conversation where it left off with this. (Yesterday&#039;s thread is at http://www.aspmessageboard.com/forum/showMessage.asp?F=20&M=377639&P=1)<BR><BR>Maybe I should give a little more background so it makes more sense. I have to clean up about 35,000 phone numbers, some US/Canadian, some international. On the web page that collected these numbers there was no form validation to control the input. You can imagine the slop I see before me. Some sample phone numbers I see are...<BR>+44 11 22 33<BR>(+44) 1122 33<BR>44(1) 12233<BR>(212) 111-1111<BR>212.111 1111<BR>( 212 ) 1111111<BR>no phone<BR>212/111-1111/12 ext 123<BR><BR>...Just a sample of the variety. Now imagine 35,000 of these. I have the task of separating US/Canadian from International then breaking them into new area code and phone fields for US/Canadian and new country code and phone fields for international. I decided using regular expressions is the only sane way to look for distinct patterns so I can apply sweeping updates to matches pattern by pattern.<BR><BR>The problem is that I don&#039;t simply want to match a pattern anywhere in a string. I want to match it starting from the beginning. I&#039;m getting confusing results. Yes, I&#039;m new to regular expressions, but I thought I had enough down to do a simple match.<BR><BR>Here are two patterns that exist in my table:<BR>+11 22 33 44<BR>11 22 33 44<BR><BR>Using this pattern...<BR>re.Pattern = "d{2}sd{2}"<BR>..."+11 22 33 44" shows up<BR><BR>Using this pattern...<BR>re.Pattern = "^d{2}sd{2}"<BR>...nothing shows up.<BR><BR>Not only did I expect "+11 22 33 44" AND "11 22 33 44" on the first one, I fully expected to get "11 22 33 44" on the second one since it&#039;s supposed to match starting at the beginning of the string.<BR><BR>Make sense? Can you see what I am doing wrong or missing?<BR><BR>Thanks everyone.

2. Senior Member
Join Date
Dec 1969
Posts
122

## Oops. Got it.

Oh Lord, I am embarrassed. The table records I was staring at did not match the recordset I was comparing it to. I was filtering numbers that began with "+". That&#039;s why it wouldn&#039;t work for "11 22 33 44". It wasn&#039;t in the recordset! Sorry to waste your time.<BR><BR>Thanks.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•