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}))"
Comments
Post a Comment