Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

已答覆 請問字串搜尋問題

  • 2011年3月9日 上午 05:57
     
     

    請問windows powershell中是否有搜尋字串時需完全符合才顯示呢?

    例如:

    test.txt內容如下

    test

    test1

    test2

    在搜尋test時我只需要找出test 這個字串

    gc .\test.txt | Select-String "test"

    結果會把test、test1、test2都找出來,查看select-string的參數好像也沒有適合的參數可用。

     

    麻煩各位大大可以解惑

所有回覆

  • 2011年3月9日 上午 07:27
     
     已答覆 包含代碼
    在結尾處,加上 \b
    gc .\test.txt | Select-String "test\b"
    



    ☞ 這裡是「免費的討論區」付費支援服務請造訪 此處享受尊榮服務
    如果回覆對您有幫助,請記得按下標示為解答」
    • 已標示為解答 airmaxit 2011年3月9日 上午 09:12
    •  
  • 2011年3月9日 上午 09:14
     
     
    感謝~alex大大的解答