0

I have a range of numbers separated by comma, which is stored in a csv file. I am trying to match first 6 digits, for example: "130001X, XYZ" can be considered a group of digits in which X can be anything (0-9).

Is it possible? Can I use Java regular expression to match these and group them to a list?

Thanks!

1300010,10 1300011,10 1300012,22 1300013,22 1300014,22 1300015,533 1300016,535 1300017,531 1300018,22 1300019,22

1300050,20 1300051,20 1300052,20 1300053,20 1300054,20 1300055,20 1300056,20 1300057,20 1300058,20 1300059,20

2 Answers 2

0

Live demo

Assuming that X is the same in X,X and YZ are also two random digits

\b130001(\d),\1\d{2}\b
0

I'm not sure if I understood your question. But if you want to match the numbers having 13000x,xxx then you can use a regex like this:

\b130001\d,\d{3}\b

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.