re = /\[buyer_(?:email|mobile|fullname|address)\] =>\s*\K.*/m
str = 'SimpleXMLElement Object
(
[error_code] => 00
[token] => 1182263526325de72aw828369e7aa
[description] => SimpleXMLElement Object
(
)
[transaction_status] => 00
[receiver_email] => myemail@gmail.com
[order_code] => 3212423
[total_amount] => 200
[payment_method] => SimpleXMLElement Object
(
)
[bank_code] => NLAZ
[payment_type] => 1
[order_description] => SimpleXMLElement Object
(
)
[tax_amount] => 0
[discount_amount] => 0
[fee_shipping] => 0
[return_url] => success.php
[cancel_url] => order.php
[buyer_fullname] => eric phuong
[buyer_email] => eric@domain.com
[buyer_mobile] => 012108609
[buyer_address] => abc
[affiliate_code] => SimpleXMLElement Object
(
)
[transaction_id] => 12345
)'
# 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