Regular expressions

R

Rok Jaklic

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
 
A

Anno Siegel

Rok Jaklic said:
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
 
R

Rok Jaklic

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
 
A

Anno Siegel

Rok Jaklic said:
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
 
R

Rok Jaklic

Anno said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top