1

I am trying to split a string of html data. Example of the command I am trying to use is:

$foo -split "<Tr*>"

It doesn't do anything. I believe that the <> are special characters and need an escape character. I have tried backtick and backslash in front of the angle brackets, but neither is working. Any advice would be great. Thanks.

PetSerAl's advice was the way I went. I think I was trying to go towards something I was more familiar with by using the splitting method. I found a good bit of info on how to parse the html data to get what I needed.

Here is the link in case anyone else is stumped on this. https://geekeefy.wordpress.com/2017/01/24/powershell-tip-parsing-html-from-a-local-file-or-a-string/

  • 2
    Relevant: https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Jacob Colvin Jun 19 '17 at 16:53
  • "*It doesn't do anything.*" - not doing what you want isn't the same as not doing anything :P "*I believe that the <> are special characters and need an escape character*" - easily tested. `'a"` will work. – TessellatingHeckler Jun 19 '17 at 17:31
  • 1
    Just for completionism: You can use the string method `.split()`, which does not use `RegEx`. With that there is no need for escaping. Else, use `[regex]::excape('')` to let the RegEx engine escape your string, – restless1987 Jun 19 '17 at 18:25
  • PetSerAl's advice was the way I went. I think I was trying to go towards something I was more familiar with by using the splitting method. I found a good bit of info on how to parse the html data to get what I needed. Here is the link in case anyone else is stumped on this. https://geekeefy.wordpress.com/2017/01/24/powershell-tip-parsing-html-from-a-local-file-or-a-string/ – Dillon Vance Jun 20 '17 at 13:51

0 Answers0