Reputation: 859
I need a regular expression for a list of numbers in a text box with carriage returns and line feeds, but no other characters.
e.g.
1234
5678
5874
3478
I have this:
Regex(@"\d\r\n${0,}?");
... but it is accepting commas when I paste them into my text box:
e.g.
1234,
5678
5874,
3478
Can someone please tell me what I'm doing wrong?
Thanks
Upvotes: 1
Views: 752
Reputation: 14921
Try * instead of {0,} - they mean the same thing.
Upvotes: 0
Reputation: 25563
Quite a lot is wrong with your Regex =)
Your regex matches the example you have given, because it matches the "8" in the second line.
Use this regex instead:
"^(\d*\r\n)*$"
Upvotes: 2