I am trying to check if a range of numbers exist in a string
Any more elegant way than this?
if (ccnumeric.contains("51")
|| ccnumeric.contains("52")
|| ccnumeric.contains("53")
|| ccnumeric.contains("54")
|| ccnumeric.contains("55"))
I can’t think of any method that satisfies this as I am checking for an int range in a string.
You could use a simple regex:
5[12345]{1}to look for a 5 followed by exactly one 1,2,3,4 or 5: