1

If I would determine if there is a presence of a number in a string what re I need to use? With this I have some issue:

string_var = "122 aaaa bbb 222"

re.search("^[0-9]$",string_var)

Thanks,

Trics
  • 189
  • 1
  • 8
  • 1
    This checks if the *entire* input is just numbers. Remove the `^` and `$` characters to check for any position. – VLAZ Nov 10 '20 at 14:13
  • See https://stackoverflow.com/a/31861306/3832970, `\d ` is enough to check for a digit. `\d+` will extract whole chunks of digits if used with `re.findall`. – Wiktor Stribiżew Nov 10 '20 at 14:14

0 Answers0