locked
Select-String where the pattern has extra spaces, but only maybe? RRS feed

  • Question

  • OK, so I'm trying to parse a large number of text files and look for a specific string of text. For this discussion we'll say I have 50 HTML files and I'm looking for the line that says "Mexican Jumping Beans." For the vast majority of these, I can simply use:

    Select-String -Pattern "Mexican Jumping Beans"

    ...and get the result I want just fine.

    However, some... [censored] has for some reason added extra spaces in on some of these documents:

    "Mexican Jumping      Beans"

    "Mexican     Jumping Beans     "

    "     Mexican Jumping    Beans"

    Obviously, I don't care about the leading or trailing spaces, but it's the lines where there's spaces between the words that are throwing off my search.

    Is there a way I can work around this...irritation?

    Thursday, June 8, 2017 11:33 PM

Answers

All replies