re = /(?m)^.*SIM ICC Id .*:*\w+(\w{6}.*)$/
str = '1,"Ready information for interface Mobile Broadband Connection:
-------------------------------------
State : Ready to power up and register
Emergency mode : Off
Subscriber Id : 123450026373881
SIM ICC Id : 00000000000000124610
Number of telephone numbers : 1
2,"Ready information for interface Mobile Broadband Connection:
-------------------------------------
State : Ready to power up and register
Emergency mode : Off
Subscriber Id : 123450026373881
SIM ICC Id : longer0000000000012342xxx10
Number of telephone numbers : 1
3,"Ready information for interface Mobile Broadband Connection:
-------------------------------------
State : Ready to power up and register
Emergency mode : Off
Subscriber Id : 123450026373881
SIM ICC Id : shorter00012342xxx10
Number of telephone numbers : 1
'
# 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