How to write a regular expression in Python?

0 votes
I want to write a simple regular expression in Python that extracts a number from HTML. The HTML sample is

Your number is <b>999</b>. So I want to extract only 999 from this. How to do it?
Jul 30 in Python by Neel
• 2,450 points
20 views

1 answer to this question.

0 votes

The following code should be able to do it. This will capture only 999 from the tag.

a = "Your number is <b>999</b>"
import re 
m = re.search(r"\d+", a)
m.group()
answered Jul 30 by Arvind
• 2,520 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

How do I check if input string is a valid regular expression or not in Python?

Hi. Good question! Well, just like what ...READ MORE

answered Feb 12 in Python by Nymeria
• 3,500 points
52 views
0 votes
1 answer
0 votes
1 answer

How to write data to a file in Python?

Refer to the below code. data=’whatever your data ...READ MORE

answered May 12 in Python by Shaam
25 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 168 views
+4 votes
6 answers
+1 vote
1 answer

How to install a module in Python 3.6 ?

If you are using Ubuntu then the ...READ MORE

answered Jun 25 in Python by Arvind
• 2,520 points
56 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25 in Python by Arvind
• 2,520 points

edited Jun 26 by Kalgi 35 views