Ask a Question related to ASP.NET General, Design and Development.
-
Dino Chiesa [MSFT] #1
Re: Phone Number Format
Ken,
your regex has to be mapped to the INPUT, not the output. by including
parens and dashes in the regex, you are guaranteeing that the normalized
version of the number ("1234567890") will not be matched.
regex string:
(\d\d\d)(\d\d\d)(\d\d\d\d)
replacement string
($1) $2-$3
applied to this input:
1234567890
generates:
(123) 456-7890
also, a tip for you, and all other regex hackers: get this tool:
[url]http://www.organicbit.com/regex[/url]
Free, small, easy, useful.
-Dino
"Ken" <k_schallmo@hotmail.com> wrote in message
news:OD9wzgfVDHA.2344@TK2MSFTNGP09.phx.gbl...> How do apply a phone number format to a string? I have the regular
> expression, but have been unable to figure out how to apply the expression
> to a string from a database. I am not trying to validate the data, but
> display the output from the database in a nice format.
> Phone number string = 1234567890
> Regular expression = ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
> Desired output = (123) 456-7890
>
> Thank you,
> Ken
>
>
Dino Chiesa [MSFT] Guest
-
Format Phone Number
I have a text feild (homephone) in MSAccess that hold phone numbers (410)543-3333 When I display these in a <CFOUTPUT>#HOMEPHONE#<\CFOUTPUT> the... -
I need to dial phone number from my browser
Hello, Did you ever have any luck with this? I need to do the same thing and am having no luck. Thanks, Steve -
query match for phone number
Why order by phone number? You need to have a formatted phone number or sorting by it will not work out very well. -
Format Phone Number String in Datagrid Column
Greetings, I have a 10 digit phone number stored as a string in a SQL server table. My datagrid currently displays it as 1234567890, but I would... -
Phone Format (770) 123-1234
Hi, How do I apply phone format in a string field? for example (770) 123-1234. Please let me know. Thanks. Eddy -
Chris Jackson #2
Re: Phone Number Format
From MSDN:
Double myDouble = 1234567890;
String myString = myDouble.ToString( "(###) ### - ####" );
// The value of myString is "(123) 456 - 7890".
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"Ken" <k_schallmo@hotmail.com> wrote in message
news:OD9wzgfVDHA.2344@TK2MSFTNGP09.phx.gbl...> How do apply a phone number format to a string? I have the regular
> expression, but have been unable to figure out how to apply the expression
> to a string from a database. I am not trying to validate the data, but
> display the output from the database in a nice format.
> Phone number string = 1234567890
> Regular expression = ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
> Desired output = (123) 456-7890
>
> Thank you,
> Ken
>
>
Chris Jackson Guest
-
Shahram Khosraviani #3
Re: Phone Number Format
hi ken
this will work ..
Response.Write(Format(Convert.ToDouble(txtPhone.Te xt), "(###) ###-####"))
Hope it helps
Shahram
"Ken" <k_schallmo@hotmail.com> wrote in message
news:OD9wzgfVDHA.2344@TK2MSFTNGP09.phx.gbl...> How do apply a phone number format to a string? I have the regular
> expression, but have been unable to figure out how to apply the expression
> to a string from a database. I am not trying to validate the data, but
> display the output from the database in a nice format.
> Phone number string = 1234567890
> Regular expression = ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
> Desired output = (123) 456-7890
>
> Thank you,
> Ken
>
>
Shahram Khosraviani Guest
-
Eddy Soeparmin #4
Re: Phone Number Format
Hi Dino,
I tried that code, but it didn't work. Here is some code snippet of mine.
Please correct me. Thanks.
<Columns>
<asp:HyperLinkColumn Text="Smoking History"
DataNavigateUrlField="legal_entity_sk"
DataNavigateUrlFormatString="SmokingHistoryList.as px?legal_entity_sk={0}"
DataTextField="legal_entity_sk" HeaderText="Smoking
History"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="cf_FullName"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="user_id" HeaderText="User
ID"></asp:BoundColumn>
<asp:BoundColumn DataField="cf_CompanyName"
HeaderText="Company"></asp:BoundColumn>
<asp:BoundColumn DataField="e_mail_work" HeaderText="Email
(Work)"></asp:BoundColumn>
<asp:BoundColumn DataField="e_mail_home" HeaderText="Email
(Home)"></asp:BoundColumn>
<asp:BoundColumn DataField="phone_business" HeaderText="Phone (Work)"
DataFormatString="(\d\d\d)(\d\d\d)(\d\d\d\d)"></asp:BoundColumn>
<asp:BoundColumn DataField="phone_home" HeaderText="Phone
(Home)"></asp:BoundColumn>
</Columns>
Eddy
"Dino Chiesa [MSFT]" <dinoch@microsoft.com> wrote in message
news:unrjBrfVDHA.208@tk2msftngp13.phx.gbl...expression> Ken,
>
> your regex has to be mapped to the INPUT, not the output. by including
> parens and dashes in the regex, you are guaranteeing that the normalized
> version of the number ("1234567890") will not be matched.
>
> regex string:
> (\d\d\d)(\d\d\d)(\d\d\d\d)
>
> replacement string
> ($1) $2-$3
>
> applied to this input:
> 1234567890
>
> generates:
> (123) 456-7890
>
>
> also, a tip for you, and all other regex hackers: get this tool:
> [url]http://www.organicbit.com/regex[/url]
>
> Free, small, easy, useful.
>
> -Dino
>
> "Ken" <k_schallmo@hotmail.com> wrote in message
> news:OD9wzgfVDHA.2344@TK2MSFTNGP09.phx.gbl...> > How do apply a phone number format to a string? I have the regular
> > expression, but have been unable to figure out how to apply the>> > to a string from a database. I am not trying to validate the data, but
> > display the output from the database in a nice format.
> > Phone number string = 1234567890
> > Regular expression = ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
> > Desired output = (123) 456-7890
> >
> > Thank you,
> > Ken
> >
> >
>
Eddy Soeparmin Guest



Reply With Quote

