Hi I have a script trying to pull out the price value from a html file. the Regex works when I assign it in the script but when I put the regex in CSV, it refuses to give me the result. Could someone help with this?
$htmlcontent = Get-Content ".\Temp.html" -Raw
$priceregex = "(?<=<span class=""a-offscreen"">\$)[\d\.]+"
Write-Host "Regex value is: " $priceregex
IF ($htmlcontent -match $priceregex){$Matches[0]}else{"Not found"}
$csvdata=Import-Csv .\WebMonitor-A.csv
$priceregex=$csvdata[0].Regex
Write-Host "Regex from CSV file is: " $priceregex
IF ($htmlcontent -match $priceregex){$Matches[0]}else{"Not found"}
The html file content looks like this:
<div class="a-section a-spacing-micro"> <span class="a-price aok-align-center" data-a-size="xl" data-a-color="base"><span class="a-offscreen">$10.95</span><span aria-hidden="true"><span class="a-price-symbol">$</span><span class="a-price-whole">10<span class="a-price-decimal">.</span></span><span class="a-price-fraction">95</span></span></span>
I have this in CSV file as a column (Regex):
(?<=<span class=""a-offscreen"">\$)[\d\.]+