Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting the first letter into uppercase in ChainScript #756

Open
dustwanderer opened this issue Nov 29, 2024 · 1 comment
Open

Converting the first letter into uppercase in ChainScript #756

dustwanderer opened this issue Nov 29, 2024 · 1 comment

Comments

@dustwanderer
Copy link

Hi, I have a small ChaiScript paste script:

clip.AsciiTextReplaceRegex("-", " ");
clip.AsciiTextReplaceRegex("et al", "& ");
# clip.AsciiTextReplaceRegex("^([a-z])", "\U$1");
return false

The third line of the script (commented out) was meant to convert the first character of the line in the clipboard into uppercase. However, it seems that ChaiScript does not recognize the "\U" modifier. I guess that I could replace that third line for 26 lines, one for each letter clip.AsciiTextReplaceRegex("^a", "A"); and so on. Is there a better method?

Thank you very much for Ditto, great program

@dustwanderer
Copy link
Author

I will answer my own question. Mi current script is:

var low2Up = ["a":"A", "b":"B", "c":"C", "d":"D", "e":"E", "f":"F", "g":"G", "h":"H", "i":"I", "j":"J", "k":"K", "l":"L", "m":"M", "n":"N", "o":"O", "p":"P", "q":"Q", "r":"R", "s":"S", "t":"T", "u":"U", "v":"V", "w":"W", "x":"X", "y":"Y", "z":"Z"];

var vClip = clip.GetAsciiString();
var vClipFirst = to_char(vClip);
var vClipFirstS = to_string(vClipFirst);
var vClipUp = low2Up[vClipFirstS];

clip.AsciiTextReplaceRegex("^([a-z])", vClipUp);

clip.AsciiTextReplaceRegex("-", " ");
clip.AsciiTextReplaceRegex("et al", "& ");

return false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant