Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

Python (Regular Expressions) I am looking at the following html and I need to extract the names in Python. I need the following code to extract the names(male and female) from a website. HTML 1MichaelJessica

OpenStudy (anonymous):

how you can determine if it's male or female?

OpenStudy (asnaseer):

I would suggest you paste that string into the Input are on the site: http://re.dabase.com/ and then play around with regex until you get it right. another good one is here: http://www.pythonregex.com/

OpenStudy (asnaseer):

**Input area

OpenStudy (anonymous):

@ Tomas The first name is male and the second is female for all of the html. <tr align="right"><td>2</td><td>Christopher</td><td>Ashley</td> <tr align="right"><td>3</td><td>Matthew</td><td>Brittany</td> <tr align="right"><td>4</td><td>Joshua</td><td>Amanda</td> <tr align="right"><td>5</td><td>Daniel</td><td>Samantha</td>

OpenStudy (anonymous):

ah i see..

OpenStudy (asnaseer):

type this into the regex box of the link I gave you and then click the Python button: <td>[^<]*</td><td>([^<]+)</td><td>([^<]+)</td>

OpenStudy (asnaseer):

Put this in the Input area: <tr align="right"><td>2</td><td>Christopher</td><td>Ashley</td>

OpenStudy (asnaseer):

sorry - I missed a .* at the start, the regex should be this: .*<td>[^<]*</td><td>([^<]+)</td><td>([^<]+)</td>

OpenStudy (asnaseer):

the web site I listed can come in very useful when dealing with regular expressions.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!