re = /((@[\w\d][\w\d_]+)\s+)?(\.[\w\d][\w\d_]+\s+)/m
str = '@array .byte 3, 4, 23
va1 .byte \'A\', -3, 0xAB // Three bytes
@str1 .byte "Enter an integer: " // Null-terminated string
@var2 .hword 0xABCD:10 // 0xABCD is replicated 10 times
@var3 .word -18, 5.7E-3 // 4-byte integer, single float
@var4 .dword 21, 21.0 // 8-byte integer, double float
//Assembly Language Syntax:
J @label // Jump @label
JAL @label // R31 = (PC+4); Jump @label
The JAL instruction saves the return address '
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html