Powershell - Regular Expression Multiple Matches

后端 未结 4 2078
庸人自扰
庸人自扰 2020-12-17 21:57

Maybe my reasoning is faulty, but I can\'t get this working.

Here\'s my regex: (Device\\s#\\d(\\n.*)*?(?=\\n\\s*Device\\s#|\\Z))

Try it: http://

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 22:34

    try this variant:

    [regex]::Matches($data,'(?im)device #\d((?!\s*Device #\d)\r?\n.)*?') | select value
    
    Value
    -----
    Device #0
    Device #1
    Device #2
    Device #3
    Device #4
    

提交回复
热议问题