Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Split Lines in a variable and compare function

$
0
0

I have a variable called $a which has multiple lines as follows:

 

Source

------

saturday:activity1

saturday:activity2

saturday:activity3

 

 

i have another variables called $b which also has multiple lines as follows

 

Files

------

[string1] text and strings

[string2] text and strings

[string3] text and strings

[string4] text and strings

 

I need a function that only takes what is in the [ ] from each line in $b, something like this:

 

Split(']')[0].TrimStart('[') # this needs to apply to each line in $b

 

and compares that to every activity in $ (which comes after the colon in each line in $a)

 

so all lines in $a need to be split, something like this: $_.Split(':') #applies to each line in $a

 

if there is at least one match across all lines, i want the outcome to say "yes", if there was no match at all, the outcome to be "No",

 

Please note that the word Saturday does exist in each line in $a.

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles