fork(2) download
  1. local matchNouns = {"<<", ">>"}
  2. local matchOther = {"%f[<]<%f[^<]", "%f[>]>%f[^>]"}
  3.  
  4. local str = "<Hello> <<world>>, <my> <<name>> <is> <<John>>"
  5.  
  6. local function printOtherMatches(str)
  7. -- Get opening and closing brackets
  8. local open, close = unpack(matchOther)
  9.  
  10. -- Concatenate opening and closing brackets with
  11. -- pattern for finding all characters in between them
  12. for other in str:gmatch(open .. ".-" .. close) do
  13. print(other)
  14. end
  15. end
  16.  
  17. printOtherMatches(str)
Success #stdin #stdout 0s 2844KB
stdin
Standard input is empty
stdout
<Hello>
<my>
<is>