Multiple String

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Vishal Joshi Vishal Joshi 5 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37878
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    Hi All,

    I was trying to match multiple strings by using below code
    $logfile = @"
    $error_Log
    "@ -split "`n"

    $logfile -notmatch 'String1' , 'String2',....
    it is not working for me
    but when i selecting only one string it is working
    $logfile -notmatch 'String1'

    Please help...

    #37881
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    The -match operator doesn't work that way. However, you can make a regular expression that does multiple patterns with its or operator (the pipe symbol). For example:

    $logfile -notmatch 'String1|String2'
    
    #38096
    Profile photo of Vishal Joshi
    Vishal Joshi
    Participant

    Thanks 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.