re = /(?=^|[A-Z]?\s)(.\d{1,2}["+-]?\s.*?)(?=MS\D\D.\d|.\d\D\D\D\D\D|.\d\D\D.\d|AW\D\D\D\D\D|AW\D\D.\d)(MS\D\D.\d|.\d\D\D\D\D\D|.\d\D\D.\d|AW\D\D\D\D\D|AW\D\D.\d)/mi
str = '14+ Ywu&rb12AiBNL
18- vu20BEBNL
^15+ vwu&ob12Ai18C
C C 20" &dg15BE23C
19- vu20AQ 5
S S 20" w16BE26S
24 MSBE 6
N 22- MSBE15N
G22 AWAiRBa
.26" AWFE 8'
# 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