Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9235481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:02:52+00:00 2026-06-18T07:02:52+00:00

Since Compare-Object cannot take wildcards, how would I compare two arrays for contents that

  • 0

Since Compare-Object cannot take wildcards, how would I compare two arrays for contents that make not be exactly the same in length or contents, but similar enough for a wildcard set or a regex to catch them.

Example:

$form = "First Name","Last Name","Address","Phone","Nickname","Fax Number"
$data = "First Name ","Last  Name","Street Address","Phone number","",Fax"

Can I compare the arrays without doing a bunch of if statements and operators? A switch would probably be more elegant, but I just so want to be able to do this on one line simlar to this:

Compare-Object ("*$form*) ("*$data*")

Instead of like this:

for($x=0;$x -lt $form.Count;$x++)
{
    [string]$xx = $x   
    if($form[$x] -like "*$data[$x]*" -or $data[$x] -like "*form[$x]*" -and $data[$x] -ne $null -and $form[$x] -ne $null)
   {
      $form[$x]
      $data[$x]
   }
   elseif($form[$x] -eq $null -and $data[$x] -eq $null)
   {
       "Form index $xx and Data index $xx are null"
   }
   elseif($form[$x] -eq $null)
   {
      "Form index $xx is null"
   }
   elseif($data[$x] -eq $null)
   {
       "Data index $xx is null"
   }
   else
   {
       "Data index $xx and Form index $xx are not even close to the same"
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:02:54+00:00Added an answer on June 18, 2026 at 7:02 am

    I doubt you will be able to find something built-in that already has the “intelligence” you outlined in your sample code.

    You could always make your own function or cmdlet to have your “one line” ability, allowing you to call it repeatedly. Or as an alternative you could write your own custom comparer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a unit test that wants to compare two complex for objects
I wrote a small app that allows me to compare two database schemas to
Using Object.Equals results in a false with two newly created objects using the same
I am creating a generic operator method that can dynamically compare two objects of
since memcpy should be highly optimized nowadays, does it still make sense to optimize
Since regular jQuery animations are not fluent on iOS ( .hide() , slideDown() ),
Since REST is stateless, each request that comes in has no knowledge of the
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain
I'm trying to compare two UIImages from the file system to see if they
I'm trying to compare custom type in two List<T> and use the Intersect /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.