How do I grab the 123 part of the following string using Python 3 regex module?
....XX (a lot of HTML characters)123
Here the ... Part denotes a long string consisting of HTML characters, words and numbers.
The number 123 is a characteristic of XX. So if anybody could suggest a universal method in which XX can be any letters like AA or AB, it would be more helpful.
Side Note:
I thought of using Perl's \G operator by first identifying XX in the string and then identifying the first number appearing after XX. But it seems \G operator doesn't work in Python 3.
My code:
import re
source='abcd XX blah blah 123 more blah blah'
grade=str(input('Which grade?'))
#here the user inputs XX
match=re.search(grade,source)
match=re.search('\G\D+',source)
#Trying to use the \G operator to get the location of last match.Doesn't work.
match=re.search('\G\d+',source)
#Trying to get the next number after XX.
print(match.group())
 
     
    
 
    