Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- NOMBRE = r'(?P<NAME>[a-zA-Z_][a-zA-Z_0-9]*)'
- NUMERO = r'(?P<NUM>\d+)'
- SUMA = r'(?P<PLUS>\+)'
- PRODUCTO = r'(?P<TIMES>\*)'
- IGUAL = r'(?P<EQ>=)'
- ESPACIO = r'(?P<WS>\s+)'
- patrones = re.compile('|'.join([NOMBRE, NUMERO, SUMA, PRODUCTO, IGUAL, ESPACIO]))
- scanner = patrones.scanner('variable = 19')
- print(scanner.match())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement