Extract a substring using PowerShell

前端 未结 8 970
灰色年华
灰色年华 2020-12-07 22:43

How can I extract a substring using PowerShell?

I have this string ...

\"-----start-------Hello World------end-------\"

I have to e

8条回答
  •  自闭症患者
    2020-12-07 23:07

    Since the string is not complex, no need to add RegEx strings. A simple match will do the trick

    $line = "----start----Hello World----end----"
    $line -match "Hello World"
    $matches[0]
    Hello World
    
    $result = $matches[0]
    $result
    Hello World
    

提交回复
热议问题