Bnaya

REGEXP 15 DIGITS V2

Jan 28th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //That what i've understood in the begging :P
  3. $str = 'aaaaaaaaaa83744484855443543bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb162539847192837ccccccccccc54354ddddddddddd304948374658903eeeeeeeeeeeeee32532532g543ferfewfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
  4. $regExp = '#(.)\1{14}#';
  5. preg_match_all($regExp, $str, $match);
  6.  
  7. var_dump($match);
  8.  
  9. //That what you need:
  10.  
  11. $str = '162539847192837ccccccccccc54354ddddddddddd304948374658903eeeeeeeeeeeeee32532532g543ferfewfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
  12.  
  13. //with subpattrens will work with all PCRE libraries i think. use this if you get regexp compile error
  14. //$regExp = '#([^0-9]|^)([1-9][0-9]{14})[^0-9]([^0-9]|$)#';
  15.  
  16. //With assertions, more Clean
  17. $regExp = '#(?<![0-9])([1-9][0-9]{14})(?=[^0-9])#';
  18. preg_match_all($regExp, $str, $match);
  19.  
  20. var_dump($match);
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment