regex - Powershell extract text from string with unknown length -


i don't think can use standard cmdlet this. have following string backup job indeterminable string here completed successfully

i need extract indeterminable string here length , number of words. text left backup job , text right either completed or failed errors.

how go this?

here go, makes use of $matches automatic variable.

$regex = "backup job (.*)(completed successfully|failed errors)" $good  = "backup job indeterminable string here completed successfully" $bad   = "backup job indeterminable string here failed errors"  if ($good -match $regex) {     $matches[1] } if ($bad -match $regex) {     $matches[1] } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -