samedi 9 mai 2015

Complicated Regex with blank lines

I am attempting to parse a regex formula in PowerShell and not having any luck. I've created the Regex and have tested it works on RegExr although when I attempt to execute a match query on it it returns no results.

The Regex is looking for any occurrence of a pattern such as below (including the TWO blank line spaces between the Price and the Address.:

$9,999,999

26 Fake Street, Fake Island, ABC 9999

my regex:\$[\d]{1},[\d]{3},[\d]{3}\n\n\n\d{1}.*?, ([A-Z])\w+ [[\d]{4}

My PowerShell code is as Below:

$Webcontent = Get-Content 'C:\Utilities\Content.txt' -Raw
[regex]::Match($WebContent,'\$[\d]{1},[\d]{3},[\d]{3}\n\n\n\d{1}.*?, ([A-Z])\w+ [[\d]{4}').Groups.Value | Out-File C:\utilities\NewContent.txt

Is it this query possible and also can it return ALL occurrences of this when it finds it?

Aucun commentaire:

Enregistrer un commentaire