Re: Regular express question

Tech-Archive recommends: Speed Up your PC by fixing your registry



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.
> >
>
>

.



Relevant Pages

  • Re: Endy Chavez
    ... were a regular for the Pirates, you might see very different numbers. ... However, I love the kid. ... "Matt" wrote in message ...
    (alt.sports.baseball.ny-mets)
  • Re: Thanks Joe!
    ... What do we do when our regular WR's return (mine was ... Jackson). ... Matt wrote in message ... > I snagged Jurevicius on Friday when I read Houshmandzadeh might not ...
    (rec.sport.football.fantasy)
  • Re: text processing problem
    ... Matt wrote: ... href="http://www.oreilly.com/catalog/regex2/index.html";>Mastering Regular Expressionsby Jeff Friedl. ... Although it's mostly geared towards Perl, it will answer all your questions about regular ...
    (comp.lang.python)
  • Re: Perl For Amateur Computer Programmers
    ... > Now that each and every regular in this group has kicked the OP at least ... (the Web sites, ... Best to beat the beast down... ... Matt ...
    (comp.lang.perl.misc)
  • Re: Is that problem for awk?
    ... And I need to extract field_1a, field_2a, ...and field_ka. ... Just for variety, here's a solution that involves using a regular ... to grab the part of the input that you do want (as opposed to the ...
    (comp.lang.awk)