re = /[^[:print:]]\[[^a-zA-Z]*[a-zA-Z]/m
str = '[BEGIN TYPESCRIPT]
[H[JLinux dcim-mao 4.19.0-20-cloud-amd64 #1 SMP Debian 4.19.235-1 (2022-03-17) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 10 08:00:55 2023 from 172.17.0.2
[?2004hroot@dcim-mao:~# cd
[?2004l
[?2004hroot@dcim-mao:~# ls
[?2004l
[?2004hroot@dcim-mao:~# cd /
[?2004l
[?2004hroot@dcim-mao:/# ls
[?2004l
app etc media public srv usr
bin home mnt root supervisor.conf var
boot lib opt run sys
dev lib64 proc sbin tmp
[?2004hroot@dcim-mao:/#
[END TYPESCRIPT]'
# 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