5 ms·
Regular expression to match line that doesn't contain a word?
- niftich 10y agoWithout getting into CS definition of a 'regular language' and how it differs from a "regex", questions like this are amusing, because they show that people are in fact attracted to very-terse-string-matching-notations. I believe regexes are a triumph of declarative (and therefore, functional) programming: tell the computer what results you want, without describing the control flow. Even though sometimes they are not the right tool for the job, the paradigm shift from declarative to imperative is often appealing enough to invite their use.
- meeper16 10y agoThe Tcl language was designed for string manipulation aka today's NLP: if {[string match "* hede *" $line] == 0} { Yay! } OR foreach line $lineData { if {$line == "hede"} { continue } }