Identifying capital letters in strings

I need to read a string (in this case a sentence) and identify any 'words' in the sentence (excluding the first word of the sentence) that begin with capital letters OR are entirely made up of capital letters. I guess I use string tokenizer to braek the string into individual words, but how do I then 'spot' capital letters (either beginnig words or all through the word)?

Here's the script that completes the task you describe (that is, to the best of my knowledge based upon your description). Enjoy!
Regards,
Brad Galiette
(Note - create a CapsLetters object and call testString; for instance:
CapsLetters myCaps = new CapsLetters();
boolean result = myCaps.testString("Hello There");
class CapsLetters{
     String caps[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
     String notCaps[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
     public boolean testString(String sentence){
          StringTokenizer sentenceWords = new StringTokenizer(sentence, " ");
          String tempStr;
          if (sentenceWords.hasMoreElements()){tempStr = sentenceWords.nextToken();}
          boolean validSentence = true;
          boolean allCaps = true;
          boolean firstCap = false;
          boolean otherCaps = false;
          while (sentenceWords.hasMoreTokens()){
               tempStr = sentenceWords.nextToken();
               allCaps = true;
               firstCap = false;
               otherCaps = false;
               int noCapsInc = 0;
               for (int i = 0; i < tempStr.length(); i++){
                    System.out.println(isCaps(tempStr.charAt(i)));
                    if (isCaps(tempStr.charAt(i))){
                         if (i == 0){
                              firstCap = true;
                         else{
                              otherCaps = true;
                    else{
                         allCaps = false;
                         noCapsInc++;
               if ((allCaps == false && otherCaps == true) || noCapsInc == tempStr.length()){
                    validSentence = false;
          return validSentence;
     public boolean isCaps(char letter){
          String letterStr = "" + letter;
          boolean capFound = false;
          for (int j = 0; j < caps.length; j++){
               if (caps[j].equals(letterStr)){
                    capFound = true;
     return capFound;
}

Similar Messages

  • Edit PSA results in CAPITAL letters

    We import data from non-SAP systems and occasionally they contain erroneous data.  We edit the PSA to make the correction and then reload.  Unfortunately we have encountered a side-effect - the character string fields are all converted to capital letters (even though lowercase is allowed).
    Any suggestions on preventing this would be appreciated.
    Ian.

    Hi Ian,
    you can try the following in the start routine of your transfer rules:
    data: l_allowedchar type rsallowchar,
          l_allchar(200) type c,
          l_uppercase type syabcde,
          l_lowercase(26) type c,
          l_strlen type i,
          l_replchar type c value space,
          l_count type i,
          l_index type i.
    select single allowchar into l_allowchar
    from rsallowedchar.
    l_uppercase = sy-abcde.
    translate l_uppercase to upper case.
    l_lowercase = sy-abcde.
    translate l_lowercase to lower case.
    concatenate l_allowedchar l_uppercase l_lowercase '0123456789' into l_allchar.
    loop at datapak into l_s_datapak_line.
    l_index = sy-tabix.
    now, for each field you want to check
    if l_s_datapak_line-<field name> cn l_allchar.
    the field doesn't contain only allowed chars
    l_strlen = strlen(l_s_datapak_line-<field name>.
    l_count = 0.
    do l_strlen times.
    l_count = l_count + 1.
    if l_s_datapak_line-<field name>+l_count(1) na l_allchar.
      l_s_datapak_line-<field name>+l_count(1) = l_replchar.
    endif.
    enddo.
    endif.
    modify datapak from l_s_datapak_line index l_index.
    endloop.
    Please check it carefully, I was writing this just from memory without any abab syntax check ....
    But in general it will replace not allowed characters with space.
    Hope this helps!
    regards
    Siggi

  • Capital letters issue with 'like'

    Hello
    Maybe it is simple but I cant find solution for this.
    For example I have table pets with column name
    "name" | "category"
    1. Tomcat | cat
    2. tomy | cat
    3. toM | cat
    4. tim | cat
    5. tOmi | cat
    query
    select name from pets where name like '%to%'
    results will give me
    2. tomy
    3. toM
    but i want as results all names wit 'to' no matter if it has capital letters or not
    1. Tomcat
    2. tomy
    3. toM
    5. tOmi
    How should i write this query ?
    please help

    Hi,
    Salski wrote:
    but I also have to remember to convert entered string in inputtext to uppercase as well
    someString.toUpperCase()You can also do that on the back-end, if that's better for you:
    select  name
    from    pets
    where   UPPER (name) like '%' || UPPER (someString) || '%'
    Thanks all for respondGlad to help!

  • Converting Capital Letters to Small Letters issue

    Half of this program works, meaning it does convert capital letters to small, but then when the letter is already small in the array as shown in the array list, I am having problems printing that out...I am confused.
    public class TesingEx3
         public static void main(String[] args)
              char[] arrayLetters = {'A', 'B', 'c', 'D', 'e', 'f', 'G', 'H'};
              // 65 = A, 90 = Z, 97 = a, 122 = z 
              for (int index = 0; index < arrayLetters.length; index++)
                   if (arrayLetters[index] >= 65 || arrayLetters[index] <= 70)
                        int letter = arrayLetters[index] + 32;
                        char convertLetter = (char) letter;
                        System.out.print(convertLetter);
                        System.out.println();
                   else
                        System.out.print(arrayLetters[index]);
                   and then here is my OUTPUT:
    ----jGRASP exec: java TesingEx3
    a
    b
    d
    g
    h
    ----jGRASP: operation complete.

    ravindra.alld wrote:
    why we make String when we do it with the help of int or byte.
    this is more memory efficient.When memory efficiency becomes a legitimate concern, we'll consider it. Until then, the choice is between using a method whose name says exactly what we're trying to accomplish, or treating characters as if they were numbers and doing arithmetic on them with the aid of magic numbers. Let the simple stuff be simple, and save your ingenuity for the hard stuff.

  • Changing the small letters to capital letters

    Hai,
    Experts,
      I retrieved the data from ADRC table into the Smartform. Then it displayed the data in small letters. How should i Change that Data in Capital letters.
    Thanks & Regards,
    Rathnam.

    Hi..
    use translate stmt..
    <b>translate <fld > to UPPERCASE</b>.
    The TRANSLATE statement converts characters into upper or lower case, or uses substitution rules to convert all occurrences of one character to another character.
    Converting to Upper or Lower Case
    TRANSLATE <c> TO UPPER CASE.
    TRANSLATE <c> TO LOWER CASE.
    These statements convert all lower case letters in the field <c> to upper case or vice versa.
    Substituting Characters
    TRANSLATE <c> USING <r>.
    This statement replaces all characters in field <c> according to the substitution rule stored in field <r> . <r> contains pairs of letters, where the first letter of each pair is replaced by the second letter. <r> can be a variable.
    For more variants of the TRANSLATE statement with more complex substitution rules, see the keyword documentation in the ABAP Editor.
    DATA: T(10) VALUE 'AbCdEfGhIj',
    STRING LIKE T,
    RULE(20) VALUE 'AxbXCydYEzfZ'.
    STRING = T.
    WRITE STRING.
    TRANSLATE STRING TO UPPER CASE.
    WRITE / STRING.
    STRING = T.
    TRANSLATE STRING TO LOWER CASE.
    WRITE / STRING.
    STRING = T.
    TRANSLATE STRING USING RULE.
    WRITE / STRING.

  • Small letters -capital letters change in Flash CS5

    hi,
    How to change the small letters to capital letters in flashCS5. Please any one tell the solution.
    thgs,

    you might have to explain exactly what you are trying a bit more
    you can use the String's toUpperCase() function.
    so if you have a textfield for example
    myTextField.text = myTextField.text.toUpperCase();
    if you want to force small letters to capitals as a user types in a textfield then you would need to add an event listener listening for teh change event and use the above code.
    if you are after something else explain in more detail please

  • Script to replace small caps that are typed as capital letters with non-capital letters (A = a, B = b, etc...)

    I'm looking for a way to replace small caps that are typed as capitals by their normal equivalent.
    I've got a text that contains a lot of names which should all be set in small caps.
    In fact they are, but because capital letters are used for first letters they don't scale.
    Short: I would like to be able to look for A, B, C... (in small caps) and replace them with (a, b, c...) in small caps in one go.
    (compare two arrays?? -> is this possible in indesign scripting)

    Hi,
    Actually, it works only with OpenType fonts and - in this case - can be managed by UI find...change feature.
    With other type of font we need a real change of contents (another keyboard hit).
    It could be done with this code (activeDocument is a target):
    -- works for Open Type as well --
    // For Latin Basic (ASCII from 65 to 90)
    // changes a "cap" letter to a "small" letter
    // if Capitalization.SMALL_CAPS is applied to
    app.findGrepPreferences = app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "\\u";
    app.findGrepPreferences.capitalization = Capitalization.SMALL_CAPS;
    var
      mSTART = 65, // ASCII number for "A"
      Mstart = 97, // ASCII number for "a"
      mDiff = 0,
      mTarget = app.activeDocument,
      mFound = mTarget.findGrep(),
      len = mFound.length, cString;
    while (len-->0) {
      cString = mFound[len].contents;
      mDiff = cString.charCodeAt(0) - mSTART;
      if (mDiff > -1 && mDiff < 26)
      mFound[len].contents = String.fromCharCode( Mstart + mDiff );
    app.findGrepPreferences = app.findGrepPreferences = null;
    Jarek

  • TS1314 Dear all, greetings, I did not mean to offend anyone by typing all my texts in capital letters, I am just used to it and at my age (63) it is better and easier for my eyes to type all the texts in my messages in capital letters.I do apologize about

    Dear all, greetings, I did not mean to offend anyone by typing all my texts in capital letters, I am just used to it and at my age (63) it is better and easier for my eyes to type all the texts in my messages in capital letters.I do apologize about it all. I can assure you that I do respect all of you more that you maight me thinking of. i have the same difficulties in typing in small letters like yours in reading texts in CAPITAL letters.......tant pis, c' est la vie
    For web and computing experts I would like to remind them that all the peoples nowadays have the same needs (or hobbies if you wish) regarding the electronic devices, web, compouters, softwares and that sort of thing.
    If I WERE not to have technical support because of my prefiously used capital letters in me text messages, I have to confess that next time I will be more carefull about the devices producers........ I live and always learn (SOCRATES, girasko, aei didaskomenos)
    Two questions
    1. I noticed on the you tube videos about the new ipad that the main icons are more than mine (i.e. the icon of facebook and a number or others are missing)
    2. I would like to ask you to do me a favour, thanks for your patiene. Still I have not understood how (in which way, the pictures, transfered from my system or new taken by the ipad camera are uploaded directly to the FaceBook. I suppose that I will not have the same difficulties regarding the videos to both Facebook AND YoutTube. Thanks a lot for your patience with me, from now on I will be more carefull about posting messages to you referring to technical support
    Constantinos
    Athens, Greece

    Some of the apps shown in adverts / videos have been downloaded from the App Store, they don't come pre-installed e.g. the Facebook app is a free download the app store : 'official' Facebook app.
    To upload photos to Facebook you can use the above app - you can't, for example, use Safari on the iPad to upload content to sites.
    Not sure whether any apps allow you to upload videos to YouTube (I don't use the site).

  • Why capital letters change in lower after copying them from a PDF document, or otherwise, why some uppercase are in fact lowercase when I look in the Text Property in any PDF Reader.

    Why capital letters change in lower after copying them from a PDF document (Made by InDesign), or otherwise, why some uppercase are in fact lowercase when I look in the Text Property in any PDF Reader.

    your home page to get into your Web site should be index.html (for Mac) or index.htm  (on PC)
    You can name it something other than index, but will be harder to find.  when you create the subjects and link to them, they can can be named anything with the html extension  Or if your using PHP end in .php. There is a Microsoft type asp or aspx but your hosting service has to set up using windows server system.
    My hosting service use a Linux server normally but can convert Windows for a Fee.  UNIX Linux has no concept of asp or aspx.
    See this : https://skitch.com/pjonescet/8mnnx/dreamweaver

  • Why is my keyboard only typint CAPITAL LETTERS?

    My keyboard only types CAPITAL LETTERS. When I restart the computer it is taking ages to boot and words "Boot Safe" appears in red on the screen. Mail search is not working and nor is spotlight

    vicentelou,
    if you made a backup of your system before installing 10.9.4, you can restore from the backup. If you didn’t make such a backup, you can do it manually by booting into Recovery mode, completely erasing your internal disk, letting OS X Internet Recovery redownload and reïnstall your MacBook Pro’s original version of OS X, running Software Update to get it up to date in-version, and if necessary redownloading Mavericks from the Mac App Store and reïnstalling Mavericks — that should get you back to 10.9.3.

  • How do i get Rosetta stone to recognize capital letters in Rosetta stone

    Yeah, so how does this happen? Capitals worked with a PC, but not w/mac. any help?

    I second shldr2thewheel.
    I use Rosetta Stone and have no issues getting capital letteres recognized.
    But in the "writing" lessons the "soft keyboard" has a "shift" key for making the capital letters available.

  • Capital letters in artist name. Difference between ipod classic and iPhone

    My ipod classic knows that "Peter Gabriel" and "peter gabriel" is the same artist. But the iphone distinguishes between the 2. This is a really annoying "feature". How come it's different? My wishlist for a iOs 4,1,1 update would be for this feature to be disabled so capital letters does not confuse the ipod software on the iphone.

    Sorry, should have said that the iPhone is a 16Gb version not 8
    Roger

  • My published Captivate 4 project has the tops of capital letters cut off

    I am using Captivate 4, on Windows 7.  My screen resolution is 1680x1050.
    When I publish my Captivate 4 project to Flash 9 HTML and view the published version, the tops of Capital letters are cut off in the text boxes.  I have resized and expanded the text boxes, and even tried moving them around, but no improvement.
    The font size in the text boxes is Arial 16, and Arial 12.
    What can I adjust so the text displays properly when published and the tops of the letters are not cut off?

    Hi there
    At any point along the way have you checked the DPI settings on your machine?
    Click Start > Run, type Desk.cpl into the dialog and press Enter
    Click the Settings tab
    Click the Advanced button
    Click the General tab (It's likely already there)
    Examine the DPI setting.
    Sometimes the DPI is set to something like 120 and it causes issues with captions. Setting to 96 often cures that.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Table entries only with capital letters

    Hi
    I have created a table with some entries.One of these is type char length 65.My problem appears when i try to add entries to my table in this field,it will automatically transform them in capital letters.Even if i write with small letters,when saving,it will save my text with capital letters.How can i change this?
    thank you.

    Hi Seba,
    Make below change in the DOMAIN for that field
    Domain
    Defination Tab
    Tick Lower Case Checkbox of Output Characteristics..
    Use
    When this attribute is activated, you can enter both upper and lower
    case letters; conversion to upper case does not then take place. Use of
    this attribute only makes sense with character formats.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • Acrobat Forms - Capital Letters throughout

    I have a form in which each field needs to be completed in capital letters, and wanted to force this through validation scripting - but I cannot work out how.
    Can someone help me please?

    Conversion.  The form is to be printed, and posted (very retro, I know), but if it is not completed in capital letters it becomes invalid.  So, I think conversion would be the most universal method.

Maybe you are looking for

  • What is the best data structure for loading an enterprise Power BI site?

    Hi folks, I'd sure appreciate some help here! I'm a kinda old-fashioned gal and a bit of a traditionalist, building enterprise data warehouses out of Analysis Service hypercubes with a whole raft of MDX for analytics.  Those puppies would sit up and

  • Upgrading from 1.6.8 and backing up

    I have a question about upgrading from 1.6.8 to the latest Mountain Lion release on my MacBook Pro. I'm really new to this whole Apple thing (been on Windows past years) so please bear with me. I've read the "Backup now" article/tip on this website a

  • CS3: PDF-Export Transparency Issue when Image-Links are missing

    I have a Layout with a transparent Frame on the top most Layer. For this Workflow-Step I do not have access to the original Image-Links, so I guess that all I see are the embedded Preview-Pictures and InDesign reports that all Object-Links are missin

  • Zoom level resets

    when zooming into the timeline and doing a preview, after the preview stops the zoomlevel resets. very annoying. is anybody else experiencing that? cheers, Ronny

  • WriteXML puts null in attribute values

    How can I avoid getting nulls in my attribute values when I use the Row.writeXML function? It causes the XSL to choke. I'd appreciate your help.