none
Powershell - Select-String -Pattern [0-99] not working as expected RRS feed

  • Question

  • Hi all,

    I have this text file with ~1000 rows. Some of the rows start with text and number like:

    Row1

    Row2

    and so on up to 99

    I want to get all rows starting with Row[x]. I tried using Select-String -Pattern 'Row[0-99]', but this gets me only the first 9 rows. How can i get the rest?

    Tuesday, January 29, 2019 9:58 AM

Answers

All replies

  • Got it - i used [0-9]?[0-9]
    • Marked as answer by Ivan Kanchev Tuesday, January 29, 2019 10:02 AM
    Tuesday, January 29, 2019 10:02 AM
  • I think you're better off writing row\d+ ("row" followed by any number of digits)

    -- Bill Stewart [Bill_Stewart]

    Tuesday, January 29, 2019 7:48 PM
    Moderator
  • Bill,

    Thank you for the suggestion. Can you show an example of what you are proposing?

    Wednesday, January 30, 2019 10:54 AM
  • Try.
    $Lines = @("Row5 is wrong","Whatever","Row row your boat","rowing34","row2456 is right","row65432")
    $Lines | Select-String -Pattern 'row\d+'
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, January 30, 2019 11:10 AM
    Moderator