UBotBuddy 331 Posted April 15, 2017 Report Share Posted April 15, 2017 Check out this code snippet. clear list(%words) set(#var,"Congressman Adam ‘Shifty’ Schiff Strikes Again","Global") add list to list(%words,$list from text($words(#var),$new line),"Don\'t Delete","Global") set(#var,$replace(%words," "," "),"Global") Do you see the odd characters in the 2nd line? Unfortunately, there is not a function in UBot to strip those out. I will likely add this to the trackeras an enhancement request and cross my fingers that it gets accepted. The 3rd line I adapted from the UBot Wiki page http://wiki.ubotstudio.com/wiki/WordsThis function, used in this manner, adds each word to the List %wordsBut if you look at the list once it is created you will see that those funky characters are no longerthere. So now, I rebuilt that sentence in the 4th line and you will see that those characters do not appear. Yeah I know. I could have used Regex but sometime it's nice to just stick with a text functionor a quick work around in my case. Later, UBotBuddy Quote Link to post Share on other sites
dr. dre 23 Posted April 15, 2017 Report Share Posted April 15, 2017 Thanks Buddy..... Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 16, 2017 Report Share Posted April 16, 2017 ‘ is a left single quotation mark’ is a right side quotation mark the problem is with the encoding and decodingif the page that its obtained from is incorrect its going to be scraped as the above. fix for ubotwe can do a regex replace to remove things, or a simple replace around it to replace the left and right side properly before reading in.it has to decode UTF-8 first, then decode the ISO 1252 encoding that produces the encoded characters shown. set(#var,"Congressman Adam ‘Shifty’ Schiff Strikes Again","Global")comment("2 replace functions used to replace the characters")set(#var2,$replace($replace("Congressman Adam ‘Shifty’ Schiff Strikes Again","‘","\'"),"€™","\'"),"Global")comment("We replace the second one first ’ otherwise †would be removed from the second one before it removes the ™")set(#var3,$replace regular expression("Congressman Adam ‘Shifty’ Schiff Strikes Again","(’|â€)","\'"),"Global")ui stat monitor("Original:",#var)ui stat monitor("2 replace functions:",#var2)ui stat monitor("Regex Replace:",#var3) Quote Link to post Share on other sites
UBotBuddy 331 Posted April 16, 2017 Author Report Share Posted April 16, 2017 You are correct. But I was looking for a solution to totally remove those characters. There are toomany of those fancy text accents for my taste so I am into ripping them out ratherthan replacing them. lol Buddy Quote Link to post Share on other sites
HelloInsomnia 1103 Posted April 16, 2017 Report Share Posted April 16, 2017 I added this to my list of small things that don't fit anywhere else. Which is a plugin I'll eventually make once I have enough of these kinds of things. In the meantime I used another newer function called $to sentence to shorten it up a bit. set(#var,$to sentence($list from text($words("Congressman Adam ‘Shifty’ Schiff Strikes Again"),$new line)),"Global") 1 Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted April 16, 2017 Report Share Posted April 16, 2017 Just adding a shorter variation of buddy's solution. set(#var,$replace($words("Congressman Adam ‘Shifty’ Schiff Strikes Again"),$new line," "),"Global") 2 Quote Link to post Share on other sites
UBotBuddy 331 Posted April 17, 2017 Author Report Share Posted April 17, 2017 LOL Thanks guy! I left my code that way so newbies could see what was going on. Sometimes commandstacking confuses new learners. @HelloInsomnia Let me know when you are ready to test out that plugin. I would like to be one of yourtesters. Buddy 1 Quote Link to post Share on other sites
deliter 203 Posted April 26, 2017 Report Share Posted April 26, 2017 LOL Thanks guy! I left my code that way so newbies could see what was going on. Sometimes commandstacking confuses new learners. @HelloInsomnia Let me know when you are ready to test out that plugin. I would like to be one of yourtesters. Buddy I hate that nested stuff, not really HInsomnia's example but that stuff with 2 or 3 nested nodes, inside a comparison operator making overall around 6 nested nodes, absolute madness, with ubots UI nodeview its just not easy to read, especially when you go trying to fix a bug 2 months after you written it and cant remember how it works, if your moving around scroll bars to see into a tiny little window to try and debug your code, your doing it wrong and yet we've all been there I'm sure! 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.