Biks 9 Posted April 13, 2011 Report Share Posted April 13, 2011 I want to change this: keyword phraseto this: Keyword phrase. I just want to change the first letter of each line to uppercase. I know the parts: ^ = Start of line\U = uppercase (\L - lowercase) I tried this: .replace(^., '\U'); Am I even close? Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted April 13, 2011 Report Share Posted April 13, 2011 If you have Pro/Dev license you can easily do that with $propercase constant. If you dont have that in your license then I dont know how to.. Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted April 13, 2011 Report Share Posted April 13, 2011 can also use javascript if you like String.prototype.capitalize = function () { return this.replace(XRegExp("^\\p{L}"), function ($0) { return $0.toUpperCase(); })} Quote Link to post Share on other sites
UBotBuddy 331 Posted April 14, 2011 Report Share Posted April 14, 2011 Guys! This is overkill for changing the first letter. Look at this. http://screencast.com/t/wMw2IDeQQfox Quote Link to post Share on other sites
Praney Behl 314 Posted April 15, 2011 Report Share Posted April 15, 2011 Good one Buddy, but I think Biks has a standard License. @TJ, good stuff Quote Link to post Share on other sites
Praney Behl 314 Posted April 15, 2011 Report Share Posted April 15, 2011 Biks, Mate can you please update your profile info, so its easy for anyone on the forum to help out knowing what license you have. Thanks, Praney Quote Link to post Share on other sites
UBotBuddy 331 Posted April 15, 2011 Report Share Posted April 15, 2011 Praney, that's as basic as it gets. Nothing special with my code. Quote Link to post Share on other sites
Biks 9 Posted April 15, 2011 Author Report Share Posted April 15, 2011 Kreatus: yea, just got the pro version. (profile updated) LoWrIdErTJ: OK, so how do I apply that to a variable? I see the "run Javascript" command, not sure where I would stick the variable (with my keyword) into it. BotBuddy: OK, I can't even recreate your example manually. I can build half of it but I don't understand what's going on. I see that $text to uppercase does it to ALL the letters and you're trying to subtract everything but the first letter. It seems you're assuming that it's a 2 word variable. {1}{2} I'm saying I want to uppercase the first word for ANY length of keywords. I could have some 4 keyword groups. That's why I thought a regex expression would deal with the variable length of words. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted April 15, 2011 Report Share Posted April 15, 2011 Here you go biks firstchartoupper.ubot 2 Quote Link to post Share on other sites
UBotBuddy 331 Posted April 15, 2011 Report Share Posted April 15, 2011 @BiksCheck out my bot it's attached now. @KreatusI gave you a +1. Your regex triggered an idea. I wish I could have incorporated your regex into mine but I am not quite there logically. I will say that I solved it in two Sets whereas you used three Sets. LOLcapitalize-1st-letter-of-phrase.ubot Quote Link to post Share on other sites
Biks 9 Posted April 16, 2011 Author Report Share Posted April 16, 2011 Thanks guys! I'm cooking with gas now! I'm new to the pro version, never knew about the additional regex choices in there. Quote Link to post Share on other sites
Walter1 8 Posted September 13, 2013 Report Share Posted September 13, 2013 Bump. I know its a old thread but any solutions for this problem with the current version? Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted September 13, 2013 Report Share Posted September 13, 2013 Bump. I know its a old thread but any solutions for this problem with the current version? Yes, it is called $change text casing now command now.. Quote Link to post Share on other sites
Walter1 8 Posted September 13, 2013 Report Share Posted September 13, 2013 Yeah i know, but it changes every first letter to upper and lower, not a option for the proper way. Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted September 13, 2013 Report Share Posted September 13, 2013 Yeah i know, but it changes every first letter to upper and lower, not a option for the proper way. I see. Im about to go to bed now. I can come up with the solution on this tomorrow. Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted September 13, 2013 Report Share Posted September 13, 2013 i had a plugin for this based on punctuation.. Quote Link to post Share on other sites
Pete 121 Posted September 13, 2013 Report Share Posted September 13, 2013 Sentence Case() define Sentence Case { clear list(%Temp) set(#TextInput, "cOnTRarY to popular belief, Lorem Ipsum is not simply random text. iT has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet..\", comes from a line in section 1.10.32.", "Global") add list to list(%Temp, $list from text($trim($change text casing($replace regular expression($replace regular expression($replace regular expression(#TextInput, "\\.", $new line), "[^\\w \\xC0-\\xFF]", " "), "\\s\\s+", $new line), "Lower Case")), $new line), "Delete", "Global") loop($list total(%Temp)) { set(#Haystack, $list item(%Temp, 0), "Global") set(#Needle, $change text casing($find regular expression(#Haystack, "(^[a-z])"), "Upper Case"), "Global") set(#Thread, $find regular expression(#Haystack, "(?<={$change text casing(#Needle, "Lower Case")}).*"), "Global") add item to list(%Temp, "{#Needle}{#Thread}.", "Delete", "Global") remove from list(%Temp, 0) } set(#TextOutPut, $replace regular expression(%Temp, "\\r?\\n", " "), "Global") clear list(%Temp) load html("<p>Input</p> <p>{#TextInput}</p> <br /> <p>Output</p> <p>{#TextOutPut}</p>") } Hell of a work around but may help Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted September 14, 2013 Report Share Posted September 14, 2013 Nice one zap. This one should work. 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.