On Sun, Apr 16, 2017 at 10:13:07PM +0200, Janus Weil wrote: > > if {![string match "" $tmp]} { > > foreach i $tmp { > > - regexp "(\[0-9\]+)\[ \t\]+(?:(?:#)?\[ \t\]*include\[ > > \t\]+)\[\"\](\[^\"\]*)\[\"\]" $i dummy lineno include_file > > + regexp -nocase > > "(\[0-9\]+)\\s+(?:(?:#)?\\s*include\\s+)\[\"\'\](\[^\"\'\]*)\[\"\'\]" $i > > dummy lineno include_file > > My regex sorcery may be a bit rusty, but why does \\s need a double > escape while \t appears with single escape?
"\t" is a tab character. "\\t" is the string \t (which in a regexp stands for a tab). "\s" is just s (since \s is not a special character). "\\s" is \s . Since you do not want any substitution in the regexp string anyway, it is way more readable if written as a braced string than as a double-quoted string: + regexp -nocase {([0-9]+)\s+(?:(?:#)?\s*include\s+)["']([^"']*)["']} $i dummy lineno include_file You can also write [0-9] as \d, and (?:#) as just # and the other (?:...) doesn't do anything either. So that gives + regexp -nocase {(\d+)\s+#?\s*include\s+["']([^"']*)["']} $i dummy lineno include_file and a little bit more work may make it fit on a line even ;-) Segher