I am looking to create a Python regular expression to match a specific pattern: The pattern always starts with any upper or lowercase letter, may have any number of letters or numbers after it, and always ends in a period (.).
For example, the pattern would match the line that has the question label (e.g: Q42.) in this HTML code:
<p>Q42. Which of the following newspapers, if any, do you read on a regular
basis? Please select all that apply:</p>
<p>NY Times</p>
<p>Chicago Tribune</p>
EDIT:
I’ve tried [a-zA-Z]\W*\.
What that says to me is any letter upper or lower followed by any number or letters upper or lower or numbers followed by a period.
EDIT:
I am just trying to test weather the entire line contains these characters or not. Only looking for a True or False.
Close:
should do it.
\Wmeans “any character except alphanumerics, so you need the opposite,\w.\bis a word boundary, ensuring that we start the match at the beginning of a word.