Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to get the index of the first integer in a string python

>>> import re
>>> s1 = "thishasadigit4here"
>>> m = re.search(r"d", s1)
>>> if m:
...     print("Digit found at position", m.start())
... else:
...     print("No digit in that string")
... 
Digit found at position 13
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #index #integer #string #python
ADD COMMENT
Topic
Name
5+6 =