0

This is my pattern:

^~[0-9]+@Y 1,710,-?[0-9]+[,-?[0-9]+]*\n$

For some reason it's match :~01@Y 1,710,9,

But not: ~01@Y 1,710,9

I don't understand why it's need the last comma?

http://regex101.com/r/kP4pZ2/1

Unihedron
  • 10,902
  • 13
  • 62
  • 72
cheziHoyzer
  • 4,803
  • 12
  • 54
  • 81

1 Answers1

-1

I think the problem here is

[,-?[0-9]+]*

It will match "~01@Y 1,710,9," or "~01@Y 1,710,[9]"

If you just want to define your expression match with comma, question mark, number or "-" at the end, you can try expression below:

^~[0-9]+@Y 1,710,-?[0-9]+[,?0-9-]*$
Unihedron
  • 10,902
  • 13
  • 62
  • 72
Mabu Kloesen
  • 1,248
  • 7
  • 8