I am a regex/powershell beginner and struggling to get this working. I am working with some HTML data and I need to be able to extract the string between given characters. In the below case, I need to extract the string (if it matches my search string) which is found between the characters > and <. I have provided multple examples here and I hope I made my question clear. Any help is greatly appreciated.
For example -
$string1 = '<P><STRONG><SPAN style="COLOR: rgb(255,0,0)">ILOM 2.6.1.6.a <BR>BIOS vers. 0CDAN860 <BR>LSI MPT SAS firmware MPT BIOS 1.6.00</SPAN></STRONG></P></DIV></TD>'
$string2 = '<P><A id=T5220 name=T5220></A><A href="http://mywebserver/index.html">Enterprise T5120 Server</A> <BR><A href="http://mywebserver/index.html">Enterprise T5220 Server</A></P></DIV></TD>'
$searchstring = "ILOM"
$regex = ".+>(.*$searchstring.+)<" # Tried this
$string1 -match $regex
$matches[x] = ILOM 2.6.1.6.a # expected result
Similarly -
$searchstring = "BIOS"
$regex = ".+>(.*$searchstring.+)<" # Tried this
$string1 -match $regex
$matches[x] = BIOS vers. 0CDAN860 # expected result
$searchstring = "T5120"
$regex = ".+>(.*$searchstring.+)<" # Tried this
$string2 -match $regex
$matches[x] = Enterprise T5120 Server # expected result
$searchstring = "T5220"
$regex = ".+>(.*$searchstring.+)<" # Tried this
$string2 -match $regex
$matches[x] = Enterprise T5220 Server # expected result
BIOS vers. 0CDAN860
LSI MPT SAS firmware MPT BIOS 1.6.00` for my 1st example – gbabu Mar 09 '15 at 17:27