re = /Representatives:\s+(?<rep_name>.*)\(.*\)\s+((?<rep2_name>.*)?\s+\()?/
str = '----------------------------------------------
SESSION SUMMARY
----------------------------------------------
Representatives:
Amoz Abraham (ID: 23)
Jose Sandoval (ID: 25)
Customer Name: [Pinned] SOUTHLAWN02
Customer\'s Public IP: 174.110.83.140:56969
Customer\'s Private IP: 10.5.65.90
Session Start Time: 2020-05-15 17:03:22 US/Pacific
Session End Time: 2020-05-15 17:11:37 US/Pacific
Duration: 00:08:15
# Files Transferred: 0
# Files Moved: 0
# Files Deleted: 0
----------------------------------------------
SYSTEM INFORMATION RETRIEVED
----------------------------------------------
## General ##
Version: Windows 10 Pro x64
Computer Name: SOUTHLAWN02
System BIOS:
Processor 1 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 2 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 3 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 4 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 5 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Processor 6 Info: Intel(R) Core(TM) i5-9500 CPU @ 3.00GHz
Default Browser: Google Chrome
Default Browser Version: 81.0.4044.138
Default Browser Location: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe
Windows® Directory: C:\\Windows
System Directory: C:\\Windows\\system32
Time Zone: Eastern Daylight Time
'
# Print the match result
str.match(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