Regular expressions

Discussion in 'Perl Misc' started by Rok Jaklic, Oct 4, 2005.

  1. Rok Jaklic

    Rok Jaklic Guest

    Hello.

    Is it possible to match with regular expressions something like this:

    XXXX
    0XXX
    XXX0

    where X is the same number for example: 1111,2222, 0111, 1110 ...

    or ABCD: for example 1234, ... 5678, 6789 ...

    And if, would "you" give me a hint or something, because I have one
    terrible solution, where I would check for every possible number
    without regular expressions...

    Thank you,

    Regards,

    Rok
    Rok Jaklic, Oct 4, 2005
    #1
    1. Advertising

  2. Rok Jaklic

    Anno Siegel Guest

    Rok Jaklic <> wrote in comp.lang.perl.misc:
    > Hello.
    >
    > Is it possible to match with regular expressions something like this:
    >
    > XXXX
    > 0XXX
    > XXX0
    >
    > where X is the same number for example: 1111,2222, 0111, 1110 ...


    /(\d)\1{3}\n0\1{3}\n\1{3}0/

    (Look up "backreference" in perlre.)

    > or ABCD: for example 1234, ... 5678, 6789 ...


    I don't understand what you are saying here.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    Anno Siegel, Oct 4, 2005
    #2
    1. Advertising

  3. Rok Jaklic

    Rok Jaklic Guest

    Hi.

    Thank you for a quick response.

    ABCD (4 numbers, where if A is for example 1, then B is A+1, C is A+2
    (or B+1) and D is A+3 (or C+1).

    Regards,

    Rok
    Rok Jaklic, Oct 4, 2005
    #3
  4. Rok Jaklic

    Anno Siegel Guest

    Rok Jaklic <> wrote in comp.lang.perl.misc:
    > Hi.
    >
    > Thank you for a quick response.


    Whom are you thanking for what response? Please provide attributions
    and some context with your reply.

    > ABCD (4 numbers, where if A is for example 1, then B is A+1, C is A+2
    > (or B+1) and D is A+3 (or C+1).


    Without context, this is just as incomprehensible as your first
    attempt.

    What is B when A is 9? A two-digit number?

    A regex isn't a good tool to recognize consecutive numbers. You should
    probably split the string into digits and use some other means.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    Anno Siegel, Oct 4, 2005
    #4
  5. Rok Jaklic

    Rok Jaklic Guest

    Anno Siegel wrote:
    > Whom are you thanking for what response? Please provide attributions
    > and some context with your reply.

    To you, since you are the only one who did replay ... ?!?!?!?

    > What is B when A is 9? A two-digit number?

    Ohh. I am sorry. I did not see this "problem". Just forget it.

    > A regex isn't a good tool to recognize consecutive numbers. You should
    > probably split the string into digits and use some other means.

    OK.
    Rok Jaklic, Oct 4, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas

    Custom Regular Expressions in ASP.net

    Jay Douglas, Nov 2, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    605
    mikeb
    Nov 3, 2003
  2. mark

    Regular expressions

    mark, Jun 30, 2003, in forum: Perl
    Replies:
    4
    Views:
    1,719
  3. Dustin D.
    Replies:
    1
    Views:
    11,194
  4. Jay Douglas
    Replies:
    0
    Views:
    600
    Jay Douglas
    Aug 15, 2003
  5. Noman Shapiro
    Replies:
    0
    Views:
    232
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page