Mufasa 0 Posted July 6, 2014 Report Share Posted July 6, 2014 Like lets say I have$List 1:123 Then I have%List 2:41434645 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. Quote Link to post Share on other sites
UBotBuddy 331 Posted July 6, 2014 Report Share Posted July 6, 2014 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") 1 Quote Link to post Share on other sites
UBotBuddy 331 Posted July 6, 2014 Report Share Posted July 6, 2014 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") 1 Quote Link to post Share on other sites
Mufasa 0 Posted July 6, 2014 Author Report Share Posted July 6, 2014 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? Quote Link to post Share on other sites
UBotBuddy 331 Posted July 7, 2014 Report Share Posted July 7, 2014 Oh yeah. This technique will work for that easily. I do that all the time. Good luck Quote Link to post Share on other sites
Mufasa 0 Posted July 7, 2014 Author Report Share Posted July 7, 2014 (edited) Oh yeah. This technique will work for that easily. I do that all the time. Good luckItll work even if its only part of the url? Which code do you suggest for that? Edited July 7, 2014 by Mufasa Quote Link to post Share on other sites
UBotDev 276 Posted July 7, 2014 Report Share Posted July 7, 2014 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. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 7, 2014 Report Share Posted July 7, 2014 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.comhttp://twitter.comhttp://facebook.comhttp://doggies.comhttp://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 1 Quote Link to post Share on other sites
Chris M 55 Posted July 7, 2014 Report Share Posted July 7, 2014 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 thatare not .com .net and .org? The url list format is url.comurl.neturl.orgurl.info Etc...etc... Quote Link to post Share on other sites
iDollarsteam 13 Posted July 7, 2014 Report Share Posted July 7, 2014 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") } } } Quote Link to post Share on other sites
iDollarsteam 13 Posted July 7, 2014 Report Share Posted July 7, 2014 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 thatare not .com .net and .org? The url list format is url.comurl.neturl.orgurl.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 ... You can make the example more versatile with regex Quote Link to post Share on other sites
UBotBuddy 331 Posted July 7, 2014 Report Share Posted July 7, 2014 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 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 8, 2014 Report Share Posted July 8, 2014 @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.neturl.comurl.meurl.usaurl.caurl.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 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted July 8, 2014 Report Share Posted July 8, 2014 Here's a few functions alert($Find by domain extension("url.neturl.comurl.meurl.usaurl.caurl.org", ".ca.me.net"))alert($Remove URLs from list("http://yahoo.comhttp://twitter.comhttp://facebook.comhttp://doggies.comhttp://ubotstudio.com", "yahootwitter"))alert($Remove by domain extension("url.neturl.comurl.meurl.usaurl.caurl.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 TCexample-regex-funcs-by-dom-n-url.ubot 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.