java - Regex to find all fixed length numbers in a bigger number -


i want match fixed length numbers, in , bigger number. example; if number is

123456 

i want obtain 123, 234, 345, 456. not looking other possible combination 135 or 654. how can achieve this?

i tried pattern \d{3} returned me 123.

thanks

you can use lookahead based regex grab 3 digit numbers using captured groups:

(?=(\d{3})) 

lookahead zero-width assertion giving ability lookahead 3 digit numbers without moving internal regex pointer.

in java use:

"(?=(\\d{3}))" 

regex demo


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -