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, 2019 in Python by Neel
• 3,020 points
212 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, 2019 by Arvind
• 3,020 points

Related Questions In Python

+1 vote
0 answers

how to match the following string without a regular expression in python

abc_pqr_0_114_004.xxx ab_pq_04_114.xxx READ MORE

Dec 17, 2019 in Python by Rajesh Babu
• 130 points
958 views
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, 2019 in Python by Nymeria
• 3,540 points
8,714 views
0 votes
1 answer

how do i print only the last two letters in a string using regular expression in python?

$ to match the end of the ...READ MORE

answered Mar 15, 2019 in Python by Waseem
• 4,540 points
332 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,472 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,853 views
+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, 2019 in Python by Arvind
• 3,020 points
467 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, 2019 in Python by Arvind
• 3,020 points

edited Jun 26, 2019 by Kalgi 7,080 views