Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell -contains

Hi,

I'd need to know if an html block contains Red, this does not work

$text = '<h3</h3> <Table>                
    <TR bgcolor=D1D0CE align=center>
    <TD><B>Name</B></TD>
    </TR>  
    <TR><TD> test</TD>
   <TD bgcolor=LightGrey align=center> </TD><TD bgcolor=Red align=center></TD><TD bgcolor=Red align=center></TD></TR><TR><TD>test</TD>'

$text.Contains('red')

How should I address it?
J.
Avatar of oBdA
oBdA

The Contains() method is case sensitive.
Try $text.ToLower().Contains('red')
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janhoedt

ASKER

Great, thanks! However, it also finds Registered :-(
H
That's something completely different ;-). To find the exact word, -match is even better suited, because you can feed in a regex. Just use '\bred\b' as search pattern.