That’s because *
is a greedy quantifier, trying to match as much as it can. Make it *?
:
q=http://.*?\.doc
More information can be found in the Regular Expression HOWTO:
Greedy versus Non-greedy
More Related Contents:
- Splitting string into words with regex
- How to make a this specific Pattern [closed]
- Regex in Python and save in csv [closed]
- Convert perl regex to python [closed]
- Is there a simple way to remove multiple spaces in a string?
- How to correctly sort a string with a number inside? [duplicate]
- Split string on whitespace in Python [duplicate]
- Regular expression to match a dot
- Python non-greedy regexes
- Match text between two strings with regular expression
- Regex to extract URLs from href attribute in HTML with Python [duplicate]
- How to replace only part of the match with python re.sub
- How to split by commas that are not within parentheses?
- Replace first occurrence of string in Python
- BeautifulSoup webscraping find_all( ): finding exact match
- In Python, how to check if a string only contains certain characters?
- How to handle response encoding from urllib.request.urlopen() , to avoid TypeError: can’t use a string pattern on a bytes-like object
- Regex: AttributeError: ‘NoneType’ object has no attribute ‘groups’
- remove unicode emoji using re in python
- Python – RegEx for splitting text into sentences (sentence-tokenizing) [duplicate]
- Python regex string matching?
- Re.match() returns always none
- How to use regular expression in lxml xpath?
- Why isn’t the regular expression’s “non-capturing” group working?
- Python Regular Expression Match All 5 Digit Numbers but None Larger
- Python regular expression for HTML parsing
- Remove Sub String by using Python
- How does python and the regex module handle backslashes?
- How to tell if one regular expression matches a subset of another regular expression?
- Perl compatible regular expression (PCRE) in Python