Posted to tcl by kbk at Sun Jul 11 20:46:03 GMT 2021view raw

  1. set s {
  2. This text contains "quoted strings"
  3. some of which contain "escaped \" characters"
  4. and even "escaped \\ characters"
  5. }
  6.  
  7. set start 0
  8. while {[regexp -indices -start $start {"([^"]|\\\"|\\\\)*"} $s result]} {
  9. lassign $result from to
  10. set matched [string range $s $from $to]
  11. puts "$from: $matched"
  12. set start [expr {$to+1}]
  13. }
  14.