Regular expression – regular expression matches two unequal numbers

I want to know how to match two numbers, but they are not the same. So, match 12, but not 11, which would be fine.

What I have now is:
I have to match a string like “P12”, I completed it with this regular expression:

^P([1 -6]{1})([1-6]{1})$

But now my question is how to match only strings that do not repeat numbers like P12 or P32.

Any help or guidance on reading materials would be greatly appreciated.

Edit:
Thank you for your answers, but I tested this in RAD (radsoftware.com.au/regexdesigner) – I know, I should mention this:/, and most of them are not working there. I saw a user posted a solution, but this is no longer visible, I don’t know why, did he delete it? Anyway: this is valid:

^P([1-6]{1})(?!)([1-6]{1}) $

Thank you!

Use this:

 ^P((1[2-6])|(2[13-6])|(3[124-6])|(4[1-356])|(5[1-46])|(6 [1-5]))$

I want to know how to match two numbers, but not the same. So, match 12, but not 11, which would be great.

What I have up to now is:
I have to match a string like “P12”, I completed it with this regular expression:

^P([1-6]{1})([1-6]{1})$

But now my question is how to only match P12 or P32 like this The number does not repeat the string.

Any help or guidance on the reading material will be greatly appreciated.

Edit:
Thank you for your answers, but I am in RAD( radsoftware.com.au/regexdesigner) tested this-I know, I should mention this: /, and most of them are not working there. I saw a user posted a solution, but this is no longer visible, I I don’t know why, did he delete it? Anyway: this is valid:

^P([1-6]{1})(?!)([1-6]{1}) $

Thank you!

Use this:

^P((1[2-6])| (2[13-6])|(3[124-6])|(4[1-356])|(5[1-46])|(6[1-5]))$

Leave a Comment

Your email address will not be published.