From: rachelms79 on
How do you delete all words containing + (plus sign)? I tried sed
's/.+.//g' but that leaves the characters not adjacent to a +.
Thanks much.

From: Janis Papanagnou on
rachelms79(a)hotmail.com wrote:
> How do you delete all words containing + (plus sign)? I tried sed
> 's/.+.//g' but that leaves the characters not adjacent to a +.
> Thanks much.

Not sure what you have in mind; providing examples would be helpful.

A . stands for any character, so you delete "any character followed
by a plus followed by any character".

If you want not single characters but arbitrary long strings you
would use the pattern .*+.* but that means you'd replace every line
with a plus by a blank one.

If you want "words", as you write, you have to define how word is
defined. If delimited by white space then you might want to use the
command

sed -e 's/[^[:space:]]*+[^[:space:]]*//g'

which produces, for example, given this input

aaa bbbb+ cccc +dddd +eee+ fff+fff ggg hhh+hh+hhh iii +++ jjj

that output

aaa cccc ggg iii jjj

If that's not what you want provide example input/output data.

Janis
From: Chris F.A. Johnson on
On 2006-01-20, rachelms79(a)hotmail.com wrote:
> How do you delete all words containing + (plus sign)? I tried sed
> 's/.+.//g' but that leaves the characters not adjacent to a +.

How do you define "word"?

Your regular expression needs to match all adjacent characters that
belong in the word, e.g.:

sed 's/[a-zA-Z]*+[a-zA-Z]*//g'

Or:

sed 's/[[:alpha:]]*+[[:alpha:]]*//g'

Or, if the word can include numbers:

sed 's/[a-zA-Z0-9]*+[a-zA-Z0-9]*//g'

etc......

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
From: Timothy Larson on
rachelms79(a)hotmail.com wrote:
> How do you delete all words containing + (plus sign)? I tried sed
> 's/.+.//g' but that leaves the characters not adjacent to a +.
> Thanks much.
>

I don't use sed very much, but + is a special character in regex
grammars I am familiar with. You might need to escape it.

Tim
From: Janis Papanagnou on
Timothy Larson wrote:
> rachelms79(a)hotmail.com wrote:
>
>> How do you delete all words containing + (plus sign)? I tried sed
>> 's/.+.//g' but that leaves the characters not adjacent to a +.
>> Thanks much.
>
> I don't use sed very much, but + is a special character in regex
> grammars I am familiar with. You might need to escape it.

It _might_ be a special character in some RE grammars. But not with
the sed the OP is using, as you may see if you re-read his posting;
he described that his pattern works as it is defined.
(Though he needs another regular expression than the one he uses.)

Janis