Jump to content
UBot Underground

Change 1st letter to uppercase


Recommended Posts

I want to change this: keyword phrase

to 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?

Link to post
Share on other sites

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.

Link to post
Share on other sites

@Biks

Check out my bot it's attached now.

 

@Kreatus

I 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. LOL

capitalize-1st-letter-of-phrase.ubot

Link to post
Share on other sites

Thanks guys! I'm cooking with gas now!

 

I'm new to the pro version, never knew about the additional regex choices in there.

Link to post
Share on other sites
  • 2 years later...
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

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...