0

I have a sample array and I try to create a rule which will filter our either of the 2 items that are present in the array.

Sample array:

$d_c_arr = @('idata', 'quanthouse', 'reuters', 'bloomberg', 'fidelity', 'nasdaq')

The items that I want to filter out are 'idata' and 'quanthouse'.

The filtering rule should adapt to the situations where either both 'idata' and 'quanthouse' exist or only one of them is present in an array.

My attempt to define the rule:

$d_c_arr | Where-Object { $_ -notlike 'idata' -or $_ -notlike 'quanthouse' }

My expected output would be:

reuters
bloomberg
fidelity
nasdaq

However, the actual output is:

idata
quanthouse
reuters
bloomberg
fidelity
nasdaq

How to properly define the rule which would filter either of the 2 selected items in the array?

1 Answer 1

1
$d_c_arr | sls -pattern 'idata|quanthouse' -notmatch

[LIVE]

Your object are .net strings so can use select-string cmdlet.
select-string takes regex as its pattern.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.