memeuu 12 Posted October 27, 2015 Report Share Posted October 27, 2015 I've tried looking around the forum to find the answer and can't seem to find the answer. So I hope someone can help me. I have a simple list: KiwikiwiBananaApplecHerryappleAPPLEoranges I want to use regex to find all occurrences of apple so it'll be like this (case insensitive):AppleappleAPPLE More specifically I want to use an if command so that if this list contains apple (case insensitive). then A, else B. Thank you Quote Link to post Share on other sites
deliter 203 Posted October 28, 2015 Report Share Posted October 28, 2015 I think this is what you mean,has a list in it toobelow this,I wrote a function a while ago for finding index's of list items(I don't think their is a Ubot function for this),mainly for local lists,wrote that below if it is of any use,never really used it myself,it is for case insensitive searching set(#items,"KiwikiwiBananaApplecHerryappleAPPLEoranges","Global")clear list(%matches)add list to list(%matches,$find regular expression(#items,"(?i)apple"),"Don\'t Delete","Global")if($comparison($list total(%matches),">",0) { then { alert("greater") } else { alert("zero") }} ========================================================================= define $List Search(#list here, #search query) { if($comparison(#list here,"=",$nothing) OR $comparison(#search query,"=",$nothing)) { then { return("-1") } else { add list to list(%myList,$list from text(#list here,$new line),"Don\'t Delete","Local") set(#position,0,"Local") loop($list total(%myList)) { if($comparison($change text casing($list item(%myList,#position),"Lower Case"),"=",$change text casing(#search query,"Lower Case"))) { then { add item to list(%result,#position,"Don\'t Delete","Local") increment(#position) } else { increment(#position) } } } } } if($comparison($list total(%result),"=",0)) { then { return("-1") } else { return(%result) } } clear list(%myList)} add item to list(%re,"we","Don\'t Delete","Global")add item to list(%re,"we","Don\'t Delete","Global")set(#dsa,$List Search(%re, "WE"),"Global")if($comparison(#dsa,"!=","-1")) { then { alert("greater") } else { alert("not found") }} 1 Quote Link to post Share on other sites
pash 504 Posted October 28, 2015 Report Share Posted October 28, 2015 More specifically I want to use an if command so that if this list contains apple (case insensitive). then A, else B. try if($comparison($find regular expression(%myList,"(?i)apple"),"!= Does not equal","")) { then { alert("found") } else { alert("not found") } } 2 Quote Link to post Share on other sites
memeuu 12 Posted October 28, 2015 Author Report Share Posted October 28, 2015 try if($comparison($find regular expression(%myList,"(?i)apple"),"!= Does not equal","")) { then { alert("found") } else { alert("not found") } }Thanks so much for your help!I think this is what you mean,has a list in it toobelow this,I wrote a function a while ago for finding index's of list items(I don't think their is a Ubot function for this),mainly for local lists,wrote that below if it is of any use,never really used it myself,it is for case insensitive searching set(#items,"KiwikiwiBananaApplecHerryappleAPPLEoranges","Global")clear list(%matches)add list to list(%matches,$find regular expression(#items,"(?i)apple"),"Don\'t Delete","Global")if($comparison($list total(%matches),">",0) { then { alert("greater") } else { alert("zero") }} ========================================================================= define $List Search(#list here, #search query) { if($comparison(#list here,"=",$nothing) OR $comparison(#search query,"=",$nothing)) { then { return("-1") } else { add list to list(%myList,$list from text(#list here,$new line),"Don\'t Delete","Local") set(#position,0,"Local") loop($list total(%myList)) { if($comparison($change text casing($list item(%myList,#position),"Lower Case"),"=",$change text casing(#search query,"Lower Case"))) { then { add item to list(%result,#position,"Don\'t Delete","Local") increment(#position) } else { increment(#position) } } } } } if($comparison($list total(%result),"=",0)) { then { return("-1") } else { return(%result) } } clear list(%myList)} add item to list(%re,"we","Don\'t Delete","Global")add item to list(%re,"we","Don\'t Delete","Global")set(#dsa,$List Search(%re, "WE"),"Global")if($comparison(#dsa,"!=","-1")) { then { alert("greater") } else { alert("not found") }}THIS IS PERFECT! Exactly what I was looking for! Thank you 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.