fork download
  1. r = /
  2. [ ]+ # match one or more spaces
  3. | # or
  4. (\*) # match one asterisk in capture group 1
  5. [ ]* # match zero or more spaces
  6. (?!\*) # not to be followed by an asterisk (negative lookahead)
  7. | # or
  8. (\n) # match "\n" in capture group 2
  9. /x # free-spacing regex definition mode
  10.  
  11. str = "Ayy ***lol* m8\n\nlol"
  12.  
  13. puts str.split(r).inspect
Success #stdin #stdout 0.01s 5768KB
stdin
Standard input is empty
stdout
["Ayy", "**", "*", "lol", "*", "m8", "\n", "", "\n", "lol"]