Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

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

s = 'xdtwkeltjwlkejt7wthwk89lk'

for i, c in enumerate(s):
    if c.isdigit():
        print(i)
        break
Comment

PREVIOUS NEXT
Code Example
Python :: count how much a number is in an array python 
Python :: django data from many to many field in template 
Python :: take first 10 row while reading csv python 
Python :: selenium get h1 text python 
Python :: Converting Dataframe from the multi-dimensional list with column name 
Python :: mapping with geopandas 
Python :: python sleep timer 
Python :: torch.load 
Python :: animations on canvas tkinter 
Python :: how to change values of dictionary in python 
Python :: how to host python flask web application 
Python :: python dataframe to excel 
Python :: how do a plot on matplotlib python 
Python :: up and down arrow matplotlib 
Python :: How to get the date from week number in Python? 
Python :: python replace with something else 
Python :: yield python 
Python :: installing required libraries in conda environment 
Python :: length of int in python 
Python :: how to make a random int in python 
Python :: selenium python get element by type 
Python :: Group based sort pandas 
Python :: f-string print 
Python :: python how to sum two lists 
Python :: how to check django version 
Python :: Dictionary convert 2 lists into a dictionary, use zip() 
Python :: random letters generator python 
Python :: input function python 
Python :: confusion matrix with labels sklearn 
Python :: notebook cell print output to file 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =