+ 2

Regex, character classes

I want to write a simple regular expression in Python that extracts a number from HTML. For example 110 The HTML sample is as follows: number is <b>123</b>

24th Feb 2021, 10:09 PM
Roza Simonyan
Roza  Simonyan - avatar
1 Answer
+ 6
the class character for digit (0-9) is r"\d"... as you want consecutives digits, you must append 'plus' sign: num = r"\d+"
24th Feb 2021, 10:19 PM
visph - avatar