Is there any RegEx which can test this scenario.
String with comma separated number where left number should be less than right. Correct example: 1,2,3 4,10,20 Incorrect example: 3,2,1 4,1,20
String can have - separator like 1-25, where left should be smaller than right and the string should not have number between this range.
Correct example: 1-50,51,52,55-60 1,2,3-10,12,20 Incorrect example: 1-50,49,20,60 2,3,1-10,11
Should I write separate function for this?
Thanks
/1-[2-9]|2-[3-9]|3-[4-9]|4-[5-9]|5-[6-9]|6-[7-9]|7-[89]|8-9/- that validates if you have only two single-digit numbers on either side of a-sign and the left one is smaller than the right one. The complexity of creating a regex for anything more than two single-digit numbers explodes, so it's extremely hard to do it by hand. So, technically the task is possible. It still shouldn't be attempted in any serious application. And I apologise for causing any headaches and/or vomit with that regex.