Jump to content

Remove from array with wildcard?


Chimaera
 Share

Recommended Posts

@jguinch I haven't actually tested your function, but I took a look. I hope Chimaera will figure it out using your inbuilt and ready-made solution. :) I think it is also important (for the exercise) to get used to looping through a multi-dimensional array and knowing the correct syntax to use. I'm happy to see Chimaera was able to figure that out himself.

Edited by czardas
Link to comment
Share on other sites

@Chimaera : for me, it's not necessary to use a loop to remove result, considering that a regex can do the job directly (see #19).

Right, but the proper pattern to use as filter in your func is not so easy to build
A simple string with keywords and delimiters is much more easy and intuitive

BTW the use of such a filter feature could be a nice add to your func  :)

Link to comment
Share on other sites

I ended up with this

$aList = _UninstallList("DisplayName", "(?i)^(?!Update for Micr)(?!Security Update for Micr)(?!Microsoft)(?!Windows Live)(?!Office)(?!NVIDIA)(?!Nero)(?!CCC)(?!Adobe)", "UninstallString", 3, 3)

One question with the regex are these 2 the same?

(?!Update for Micr)(?!Security Update for Micr)

 

Link to comment
Share on other sites

^(?!text) = beginning of the string non followed by "text" (meaning : "text" doesn't stand at the beginning of the string) , thus the regex are not the same

$s = "abcd"
If stringregexp($s, '^(?!b)') Then msgbox(0,"", "the string doesn't begin with b")
If not stringregexp($s, '^(?!a)') Then msgbox(0,"", "the string begins with a")

Edit
You could build the pattern from a string like this

$sExclude = "Update for Micr|Security Update for Micr|Microsoft|Windows Live|Office|NVIDIA|Nero"

$pattern = "(?i)^(?!" & $sExclude & ")"
Msgbox(0,"", $pattern)

 

Edited by mikell
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...