I am trying to write some script in python (using regex) and I have the following problem:
I need to make sure that the string contains ONLY digits and spaces, but can contain any number of numbers.
The value must correspond to the lines: "213" (one number), "123 432" (two numbers) and even "123 432 543 3 235 34 56 456 456 234 324 24" (twelve numbers).
I tried searching here, but all I found was how to extract numbers from strings (and vice versa) - and this does not help me guarantee that ALL OF THE STRING weather contains ONLY digits (separated by any number of spaces).
Anyone have a solution?
If someone knows a class that contains all special characters (such as! $ # _ -), that would be great (because then I could just do [^ AZ] [^ az] [^ special class] and therefore get something that doesn't match any characters and special characters, leaving me with only numbers and spaces (if I'm right).
source
share