I have a paragraph like this:
"Nothing is worth more than the truth.
I like to say hello to him.
Give me peach or give me liberty.
Please say hello to strangers.
I'ts ok to say Hello to strangers."
I want to result:
"Nothing is worth more than the truth.
Give me peach or give me liberty."
if a line uses the word "hello" then remove that line and take only the line without that word.
I find some information in reference:
so I think ít as follow: regexp "^[^hello]" $line but it doesn't work
There are several problems with your attempt of:
A good practice with Tcl regular expressions is to put your regex inside curly braces instead of double quotes. Square brackets inside double quotes will be evaluated by Tcl as a command.
^means the beginning of the line in regular expression.Characters inside square brackets in a regular expression are considered a "character-class".
[^hello]does not mean the opposite of matching "hello". Instead, it matches a single character that is noth,e,l, oro.Do you care about case? If not, then add
-nocase.A Tcl expression, which you can use in an
ifstatement to check that a line does not include "hello" (or "Hello") is simply this: