Re: Format string using regular expressions
- From: Pavel Minaev <int19h@xxxxxxxxx>
- Date: Sun, 3 Aug 2008 23:31:43 -0700 (PDT)
On Aug 3, 6:54 pm, "Alexander Vasilevsky" <m...@xxxxxxxxx> wrote:
There is a phone number in a string such as "3223223" to format it as a
"322-32-23", using regular expressions. Is it possible?
Regular expressions are used to parse strings, not to format them. Can
you clarify why you think you need them here?
In the specific case that you give, what's wrong with this:
var result = string.Format("{0}-{1}-{2}", input.Substring(0, 3),
input.Substring(3, 2), input.Substring(5, 2));
.
- References:
- Format string using regular expressions
- From: Alexander Vasilevsky
- Format string using regular expressions
- Prev by Date: Re: Large App icon?
- Next by Date: Random behaviour accessing a share
- Previous by thread: Format string using regular expressions
- Next by thread: Catching exceptions thrown by an asynchronous call
- Index(es):
Relevant Pages
|