Python regex, how-to group an item within a regex
I'm having trouble creating a regex. Here is a sample of the text on which the regex should work:
<b>Additional Equipment Items</b> <br>
40001 <br>
1 Battery Marathon L (8 cells type L6V110) <br>
40002 <br>
What I now want to select is >>1<< and >>Battery Marathon L (8 cells type L6V110)<<.
Therefore I have produced the following Regex:
found = re.findall('<b>.*Items\s*<\/b>\s*<br>(?:\s*[1-4]0[0-9][0-9][0-9] <br>\s*(\d*) (.*) <br>)*', content)
Seems like the outer regex does match, but the inner groups are empty :(
开发者_StackOverflow中文版Any suggestions?!
Okay I sometimes just hate Regex. Some whitespaces owned me...
Here is the solution:
<b>.*Items\s*<\/b>\s*<br>(?:\s*[1-4]0[0-9][0-9][0-9] <br>\s*(\d*)\s*(.*) <br>)
精彩评论