Re: Regular express question
- From: "Brandon Gano" <bgano@xxxxxxxxxxxxxx>
- Date: Mon, 16 Jul 2007 21:30:15 -0700
Try something like this (not tested):
(.*\D+)?(\d*)
"Matt" <Matt@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:AB793CB1-9B1E-4C9D-B16E-CADC4B00A107@xxxxxxxxxxxxxxxx
Sorry, should be
123 => null, 123
"Matt" wrote:
Yes, it works. Thanks.
However, there is another match, for a number
123 => 123, null
how to add this one to the regular express?
"Brandon Gano" wrote:
> I'm unfamiliar with the <first> <second> syntax you're using, but the
> following regular expression works for the three samples given:
>
> Regex.Replace("OP001", @"(.*\D+)(\d*)", @"$1, $2"); // Returns: "OP, > 001"
> Regex.Replace("ST02", @"(.*\D+)(\d*)", @"$1, $2"); // Returns: "CD, 02"
> Regex.Replace("00A", @"(.*\D+)(\d*)", @"$1, $2"); // Returns: "00A, "
>
>
> "Matt" <Matt@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:FC2AA1A9-0C39-467C-B473-138C75B2C75C@xxxxxxxxxxxxxxxx
> >I have the following words, and I want to extract the first part and > >the
> > trailing numbers.
> >
> > OP001 => ABC, 001
> > ST02 => CD, 02
> > 00A => 00A, null
> >
> > I have the following regular express:
> > (?<first>.*?)(?<second>\d+)
> > This one works well for the given first two examples but not the > > third
> > one.
> >
> > And (?<first>.*?)(?<second>\d+)$ returns strange result.
> >
>
>
.
- References:
- Re: Regular express question
- From: Brandon Gano
- Re: Regular express question
- Prev by Date: Windows DPI settings
- Next by Date: Windows DPI settings
- Previous by thread: Re: Regular express question
- Next by thread: WindowsService/InstallUtil:Pass user/pwd from commandline to installer
- Index(es):
Relevant Pages
|