Python Forum

Full Version: Trying to extract Only the capitol letters from a string of text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I'm a bit of a newbie with Python, but I'm familiar enough with C++ and JavaScript that I can read code and have a good idea what it's supposed to do-I just suck at writing it off the top of my head. lol

I have multiple text messages I'm trying to sift through and for reasons I'm too lazy to explain--lost a bet, basically lol--I need to pull out only the Capitol Letters from large text strings.

I'm currently using Ubuntu Studio and using Terminal. Looking for something command line based that I can easily copy and past from. Can anyone point me in the right direction so I can get it up and working? Any help would be Greatly appreciated. Thank you. :-)
show what you've tried so far, and where specifically you need help.
If you can get your "large text strings" into a python string (read a file or simply cut/paste) you can just loop through it using the .isupper() string function to pluck out the capital letters.

You could also use a Linux script and a little RegEx (Regular Expressions) magic.
https://www.linuxnix.com/regular-expressions-linux-i/ The regex for uppercase is either [A-Z] or [:upper:].