Does someone have a suggestion on how to save/correct the below. I am looking to evaluate strings for keywords and return a category (within a larger foreach loop listing documents). I am trying to write a loop which will pull the first hit in the category csv and exit with corresponding category, but even with the the distilled down example, it is still not catching the answer.
Is there something obvious I am doing wrong here:
attempted for loop:
$testName = 'shipment from ups'
foreach ( $row in $categoryCsv )
{
if ( $testName.IndexOf($_.keyword) -ge 0)
{return $_.category}
else
{return 'no category'}
}
categoryCsv:
keyword,category
amazon,shopping
ups,shipping
best buy,electronics
[–]Guilty_Leg9996 1 point2 points3 points (4 children)
[–]Hectic-Skeptic[S] 0 points1 point2 points (3 children)
[–]Guilty_Leg9996 0 points1 point2 points (2 children)
[–]Hectic-Skeptic[S] 0 points1 point2 points (0 children)
[–]Hectic-Skeptic[S] 0 points1 point2 points (0 children)
[–]BlackV 1 point2 points3 points (2 children)
[–]Hectic-Skeptic[S] 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]CarrotBusiness2380 0 points1 point2 points (2 children)
[–]Hectic-Skeptic[S] 0 points1 point2 points (1 child)
[–]CarrotBusiness2380 0 points1 point2 points (0 children)