I have follwing script and the script outputs a array like below.
[
[0] "# bash LAN\n\n```\nnmap -sn 192.168.3.*\n```\n",
[1] "# node.js npm\n\n`sudo apt update && sudo apt install nodejs npm -y`\n",
[2] "# something title\n\nsomething content\n",
[3] "# bash log\n\n```\ntail -f",
[4] "# or",
[5] "# tail -f -n 50\n```\n\n\n"
]
Encoding.default_external = 'UTF-8'
require 'pry'
require "awesome_print"
# p \
ap \
arrayobj = <<-'EOS'.scan(/^#(?!#).*(?:\R(?!#(?!#)).*)*/) # .scan(/^#.*$\n(.*)/m)
# bash LAN
\```
nmap -sn 192.168.3.*
\```
# node.js npm
`sudo apt update && sudo apt install nodejs npm -y`
# something title
something content
# bash log
\```
tail -f
# or
# tail -f -n 50
\```
EOS
I'd like to split the EOS-enclosed text by #
(single hash) but if the single hash is enclosed by Markdown code tag, ignore that single hash.
So, in that case, what I wanted is following output. How do you get the output?
[
[0] "# bash LAN\n\n```\nnmap -sn 192.168.3.*\n```\n",
[1] "# node.js npm\n\n`sudo apt update && sudo apt install nodejs npm -y`\n",
[2] "# something title\n\nsomething content\n",
[3] "# bash log\n\n```\ntail -f\n# or\n# tail -f -n 50\n```\n\n\n",
]