fork download
  1. import re
  2.  
  3. user_cmd = ' 12 0b110110 \' \' " " "str" \'str\''
  4. pattern = r" (?:0b[10]+|[0-9]+|'[^']+'|\"[^\"]+\")"
  5.  
  6. print(re.findall(pattern, user_cmd))
Success #stdin #stdout 0.03s 9332KB
stdin
Standard input is empty
stdout
[' 12', ' 0b110110', " ' '", ' " "', ' "str"', " 'str'"]