I would like to create regular expressions that reuse the regular expression in the new regular expression.
Is this possible in Ruby?
For example, to simplify this parsing, similar to assembly:
LABELED_INSTR = /(\w+):(movi|addi)\s+(\w+),(\w+),(w+)/ NON_LABELED_INSTR = /(movi|addi)\s+(\w+),(\w+),(w+)/
I would like to resort to:
IMMEDIATE = /(movi|addi)/
But then I do not know how to share this regular expression in the previous two.
Any clues?
source share