-1

I want check a string with this Patern:

Pattern.compile("^0*(([a-q]{6,}|[A-Q]{6,}){6,24})(1{6,})(([a-q]{6,}|[A-Q]{6,}){6,24})(1*0*$)");

The length of [a-q] can not be more than 6. And the length of [a-qA-Q] can not be more than 24.

For example: max 24(min 6(aaaaaa)AAAAAAAbbbbbbbbb)111111...

But the code use the group (aaaaaa) like 1 element, and should count like 6 elements. And i need use OR to [a-q]|[A-Q].

How can i do this with 1 pattern?

ajb
  • 31,309
  • 3
  • 58
  • 84
Tino
  • 1
  • 1
  • I think you're looking for something similar to this http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator – Richard Oct 13 '14 at 18:11
  • post some ex for positive and negative matches. – Avinash Raj Oct 13 '14 at 18:15
  • Not really, i need check the string aaaaaaaaAAAAAAA have lowercase or uppercase in a group at least 6 size and all the string is less than 24 size. Can you help with a example? – Tino Oct 13 '14 at 18:29

1 Answers1

0

not sure if I understood your question correctly but try this pattern

^(?=.*([a-qA-Q])\1{5,})[a-qA-Q]{6,24}$  

Demo

alpha bravo
  • 7,838
  • 1
  • 19
  • 23
  • No but thanks, i want know a small pattern first, and then a big pattern with all the smalls, for example, aaaaaa or AAAAAA is my small pattern, (i need the same character repeat in lower or upperCase at least 6 times) And then i need a that this pattern are smaller than 24 characters include. x ([a-q]{6,}|[A-q]{6,})* and this repeat x times... and all characters insite this expression have to are less than 24Sorry is dificult to me explain this. – Tino Oct 13 '14 at 22:33