Jump to content
UBot Underground

How do you remove a list of stuff you dont want off a list?


Recommended Posts

Like lets say I have

$List 1:

1

2

3

 

Then I have

%List 2:

41

43

46

45

 

So I want to remove all list items in %List 2 that contain a 1,2,or3.

So I would want to remove 41 and 43. Is there anyway to do this in a easy orderly fashion.

Link to post
Share on other sites

The best way is to have list containing the items you want to be removed and then use the $subtract from list function.

That means for your example that 41 and 43 would have to be in that removal list. Unfortunately, just using 1, 2, and 3 is not good enough to remove 41 or 43.

Here is an example.
 

add list to list(%list1, $list from text("1,2,3,4,5,6,7,8,9", ","), "Delete", "Global")
add list to list(%list2, $list from text("41,42,43,44,45,46,47,48,49", ","), "Delete", "Global")
comment("List1 was not removed from List2")
add list to list(%list3, $subtract lists(%list2, %list1), "Delete", "Global")
add list to list(%list4, $list from text("41,43,45,47,49", ","), "Delete", "Global")
comment("This list only showing the items
from list2 and without the items
from list4.")
add list to list(%ThisWorked, $subtract lists(%list2, %list4), "Delete", "Global")

  • Like 1
Link to post
Share on other sites

A better example.

add list to list(%Original, $list from text("41,42,43,44,45,46,47,48,49", ","), "Delete", "Global")
add list to list(%RemoveThese, $list from text("41,43,45,47,49", ","), "Delete", "Global")
add list to list(%ThisWorked, $subtract lists(%Original, %RemoveThese), "Delete", "Global")

  • Like 1
Link to post
Share on other sites

 

A better example.

add list to list(%Original, $list from text("41,42,43,44,45,46,47,48,49", ","), "Delete", "Global")
add list to list(%RemoveThese, $list from text("41,43,45,47,49", ","), "Delete", "Global")
add list to list(%ThisWorked, $subtract lists(%Original, %RemoveThese), "Delete", "Global")

Thank you for the reply. Im not planning on using this for numbers though. Like if I scraped a bunch of url's I might want to remove any containing google facebook or twitter. Get what Im saying?

Link to post
Share on other sites

Oh yeah.

 

This technique will work for that easily.  I do that all the time.

 

Good luck

Itll work even if its only part of the url?

 

Which code do you suggest for that?

Edited by Mufasa
Link to post
Share on other sites

Itll work even if its only part of the url?

 

Which code do you suggest for that?

it won't work if you have only partial URLs. You can use "remove from list" command to remove element once you identify it.

Link to post
Share on other sites

if your brave enough for some regex here is a kinda simple way to do it

 

clear list(%clean urls)
set(#scrape list"http://yahoo.com
http://twitter.com
http://facebook.com
http://doggies.com
http://ubotstudio.com""Global")
add list to list(%clean urls$list from text($replace regular expression(#scrape list".*(yahoo|facebook|ubot).*"$nothing), $new line), "Delete""Global")

 

so you put what you want to remove between () separated by the bar | ...means or, then .* gets the stuff around what you want -before and after-. Notice I only put ubot, it will find partial text too.

 

I strongly recommend learning regex, it's a great friend indeed.

 

Also,you can put $scrape attribute in where I have #scrape list.

 

TC

  • Like 1
Link to post
Share on other sites

How could you do that with urls?

 

If you have a list of urls and you remove domains with numbers and dashes and also any that

are not .com .net and .org?

 

The url list format is

 

url.com

url.net

url.org

url.info

 

Etc...etc...

Link to post
Share on other sites

if you want to remove only the elements that CONTAINS the elements (patterns) in the first list then this is a way to do it.

In the end you will have the Results list made only from elements that don't contain any of the patterns - in our example 35 elements from the 100 elements in Base List:

comment("Creating the lists for the example")
divider
comment("This is the list with the patterns You want to remove elements that contain this")
clear list(%Patterns)
add list to list(%Patterns, $list from text("1,2,3,4", ","), "Delete", "Global")
comment("This is the base list - you want to remove items from here if they contain the patterns in list Patterns")
clear list(%Base List)
set(#item, 1, "Global")
loop(100) {
    add item to list(%Base List, #item, "Delete", "Global")
    increment(#item)
}
divider
comment("Example start:")
clear list(%Results)
set list position(%Base List, 0)
comment("We check every item in Base list if contain the patterns in Patterns list")
loop($list total(%Base List)) {
    set(#item, $next list item(%Base List), "Global")
    set list position(%Patterns, 0)
    comment("We define a check- is 0 by default and it will turn to 1 if the item contains the Pattern")
    set(#ItemContainsPattern, 0, "Global")
    comment("we check the Base Item with every pattern")
    loop($list total(%Patterns)) {
        set(#Pattern, $next list item(%Patterns), "Global")
        if($contains(#item, #Pattern)) {
            then {
                comment("if base item contains the pattern will set the check to 1")
                set(#ItemContainsPattern, 1, "Global")
            }
            else {
                comment("if the base item don\'t contain the pattern nothing happen")
            }
        }
    }
    comment("We ad the base item to a new list if it does not contain the pattern")
    if($comparison(#ItemContainsPattern, "=", 1)) {
        then {
        }
        else {
            add item to list(%Results, #item, "Delete", "Global")
        }
    }
}

Link to post
Share on other sites

How could you do that with urls?

 

If you have a list of urls and you remove domains with numbers and dashes and also any that

are not .com .net and .org?

 

The url list format is

 

url.com

url.net

url.org

url.info

 

Etc...etc...

 

You can use the above example to do that... Replace "1,2,3,4" in the pattern list with ".com, .org, .net, .info" and modify the code to save in the result list the elements that CONTAIN the patterns (now it save the elements that DON'T CONTAIN the patterns) ... Also replace the base list with your list of urls :D ... You can make the example more versatile with regex

Link to post
Share on other sites

Lots of GREAT info in here!!!

 

I totally agree with TC learning Regex will add so many more capabilities to your botting that you will later appreciate.

 

Buddy

Link to post
Share on other sites

@cmmorriss1

 

comment("put what u want to find in UI")
ui block text("Negative List"#Negative List)
ui button("Find it") {
    set(#find$find regular expression("url.net
url.com
url.me
url.usa
url.ca
url.org"".*({$text from list($list from text(#Negative List, $new line), "|")})"), "Global")
    alert(#find)
}

 

 

I called it a "negative list" cuz I was going to a remove with replace with regex, instead just did find. But same applies

 

TC

Link to post
Share on other sites

Here's a few functions

 

alert($Find by domain extension("url.net
url.com
url.me
url.usa
url.ca
url.org"".ca
.me
.net"))
alert($Remove URLs from list("http://yahoo.com
http://twitter.com
http://facebook.com
http://doggies.com
http://ubotstudio.com""yahoo
twitter"))
alert($Remove by domain extension("url.net
url.com
url.me
url.usa
url.ca
url.org"".org
.ca
.usa"))
define $Find by domain extension(#list from text#expresion list) {
    return($find regular expression(#list from text".*({$text from list($list from text(#expresion list, $new line), "|")})"))
}
define $Remove URLs from list(#list from text#expresion list) {
    return($replace regular expression(#list from text".*({$text from list($list from text(#expresion list, $new line), "|")}).*"$nothing))
}
define $Remove by domain extension(#list from text#expresion list) {
    return($replace regular expression(#list from text".*({$text from list($list from text(#expresion list, $new line), "|")})"$nothing))
}

 

download below
 

TC

example-regex-funcs-by-dom-n-url.ubot

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...