egrep string except when preceded by underscore

having trouble with this seemingly simple taks.. :mad:

Test data:

we want to keep lines 2,3 & 4

-- want to exclude when ${.*schema} is preceded with an underscore; Valid {.*schema} should always be preceded spaces or be found at the beginning of a line.

 
egrep "[^_][$]{.*schema}\."

I would like to thank whomever looks at this in advance for your time .

egrep '^\${[^}]*schema}|[^_]\${[^}]*schema}'

or :

egrep '(^|[^_])\${[^}]*schema}' 

Won't this not work for you?

fgrep '_${' file

Hi editaguy, the OP was trying to match patterns without the preceding underscore. They should also be matched when at the beginning of a line.

Oooops....sorry some how I missed it.
Then will this work?

sed '/_\${.*schema}/ {/ \${.*schema}/!d;}' file