0

I created a list and then read in data from a database table.

[System.Collections.ArrayList]$RawNotes = @()

I read in the data to the list:

foreach ($TmpRow in $Datatable) {
    $RawNotes.Add($TmpRow.Notes) | Out-Null
}
   

When I try to find the items that start with a section sign and a period my match never returns true so I am not sure what I am missing.

 if ($RawNotes[$index] -match ("^\s*§\.")) {
    $RawNotes[$index] = $RawNotes[$index]  -replace "^\s*§\.", ""
 }

I tried to use the unicode equivalent [U+00A7] but that did not work either.

Any help would be appreciated.

  • 2
    The regex works as intended `'§.foo' -replace "^\s*§\."` there is not enough information to help you – Santiago Squarzon May 15 '23 at 03:47
  • 2
    If your `$RawNotes[$index]` contains a multiline string, you'll need regex `(?m)^\s*§\.` – Theo May 15 '23 at 09:26
  • I am trying to delete the section sign character and a period. What is odd, I ran the command from the terminal and it replaced the characters, but when I run it from a script it does not replace the characters. I tried to use match to see when there is a section sign character followed by a period, but this does not match. `if ($RawNotes[$index] -match ('^\s*§\.'))` I read the data from a database record. Is there something with the encoding? The database collatoin is SQL_Latin1_General_CP1_CI_AS – Ken Kazinski May 16 '23 at 01:00

0 Answers0