sed - output lines with one word

Josh McFarlane <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <CAGnr9c7AwN1K07AgNTGjq_Juc61itv=9q89+YeKTUCt8N1NSdQ@mail.gmail.com>
I believe I have found a potential bug in sed extended regular
expressions. I was trying to output lines containing only one word
from a text file. However, I found my expression to match more than it
should have.
Using the following command:
$sed -n -r '/^\s*[^\s]+\s*$/p' test.txt

Where test.txt conatins:
a
	 b
a b

Produces the following output:
 a
	 b
a b

In my opinion this is an unexpected behavior as this regular
expression should only print lines where there is zero or more
whitespace characters, followed by one or more non whitespace
characters, followed by zero or more whitespace characters, followed
by the end of the line.

I hope that this was of help.
Regards,
Josh McFarlane.

$ sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE,
to the extent permitted by law.

GNU sed home page: <http://www.gnu.org/software/sed/>
<http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>
<http://www.gnu.org/gethelp/>.
E-mail bug reports to: <[email protected]> <[email protected]>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.