-   Programming (
-   -   regular expressions ~ white spaces (

stevie_velvet 07-14-2006 01:54 PM

regular expressions ~ white spaces
this should be simple but it driving me....
i'm using grep -e (or egrep to only find 'ted-1' ~ but the white space isn't wokirng

from the file
ted-1 ted-11 ted-111

grep -e "ted-1[\s]" file

ta for any help

Hobbletoe 07-14-2006 02:22 PM

I don't think you want grep ...
The grep command is usually used to pull the entire line out of a file. The sed command might be better for this as you can pull out just a specific part of the line. You could use grep to find the line in the file, then use sed to pull out the section that you want. I've been looking at it, but my sed skills aren't all that great.

homey 07-14-2006 02:30 PM

How about grep -o ?

grep -o "ted-1 " file.txt

stevie_velvet 07-15-2006 11:28 AM

thanks both! i'll look up the -o option
it's to simple

both solutions search for the spcific occureence

grep -w "ted-1" file
grep "ted-1\b" file

i had the wrong regular expression

All times are GMT -5. The time now is 12:44 PM.