re = /(?m)(?<Changed>^[^-]*$)/m
str = 'Changed Attributes:
SAM Account Name: -
Display Name: -
User Principal Name: -
Home Directory: -
Home Drive: -
Script Path: -
Profile Path: -
User Workstations: -
Password Last Set: -
Account Expires: -
Primary Group ID: -
AllowedToDelegateTo: -
Old UAC Value: 0x10
New UAC Value: 0x1DA11
User Account Control:
Account Disabled
\'Don\'t Expire Password\' - Enabled
\'Encrypted Text Password Allowed\' - Enabled
\'Smartcard Required\' - Enabled
\'Not Delegated\' - Enabled
\'Use DES Key Only\' - Enabled
\'Don\'t Require Preauth\' - Enabled
User Parameters: -
SID History: -
Logon Hours:'
# 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