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.
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
$text.Contains('red')
How should I address it?
J.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great, thanks! However, it also finds Registered :-(
H
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.
Try $text.ToLower().Contains('