String list manipulation

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have a string list including some words. For example, I have



words=cut, was, saw, clear, sharp, keen, tree, these;


I want to write a code that changes the first letter of each word to the capital letter. I mean I want to have the result as



Cut, Was, Saw, Clear, Sharp, Keen, Tree, These;


How can I figure it out?










share|improve this question

















  • 1




    It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
    – Kuba♦
    Aug 21 at 5:24











  • Strings go between " quotes in Mathematica.
    – Szabolcs
    Aug 21 at 7:31














up vote
2
down vote

favorite












I have a string list including some words. For example, I have



words=cut, was, saw, clear, sharp, keen, tree, these;


I want to write a code that changes the first letter of each word to the capital letter. I mean I want to have the result as



Cut, Was, Saw, Clear, Sharp, Keen, Tree, These;


How can I figure it out?










share|improve this question

















  • 1




    It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
    – Kuba♦
    Aug 21 at 5:24











  • Strings go between " quotes in Mathematica.
    – Szabolcs
    Aug 21 at 7:31












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I have a string list including some words. For example, I have



words=cut, was, saw, clear, sharp, keen, tree, these;


I want to write a code that changes the first letter of each word to the capital letter. I mean I want to have the result as



Cut, Was, Saw, Clear, Sharp, Keen, Tree, These;


How can I figure it out?










share|improve this question













I have a string list including some words. For example, I have



words=cut, was, saw, clear, sharp, keen, tree, these;


I want to write a code that changes the first letter of each word to the capital letter. I mean I want to have the result as



Cut, Was, Saw, Clear, Sharp, Keen, Tree, These;


How can I figure it out?







list-manipulation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 21 at 4:49









Hadi Sobhani

1286




1286







  • 1




    It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
    – Kuba♦
    Aug 21 at 5:24











  • Strings go between " quotes in Mathematica.
    – Szabolcs
    Aug 21 at 7:31












  • 1




    It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
    – Kuba♦
    Aug 21 at 5:24











  • Strings go between " quotes in Mathematica.
    – Szabolcs
    Aug 21 at 7:31







1




1




It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
– Kuba♦
Aug 21 at 5:24





It is not clear what do you mean by 'string list', there are no strings in words. Also, have you tried searching documentation for string related functions that could help you?
– Kuba♦
Aug 21 at 5:24













Strings go between " quotes in Mathematica.
– Szabolcs
Aug 21 at 7:31




Strings go between " quotes in Mathematica.
– Szabolcs
Aug 21 at 7:31










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










If the input and the desired output are lists of Strings:



strings = "cut", "was", "saw", "clear", "sharp", "keen", "tree", "these";

GeneralUtilities`ToTitleCase[strings]



"Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




Alternatively, you can use StringReplace:



StringReplace[strings, WordBoundary ~~ a_ :> ToUpperCase[a]]



"Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




If the input and desired output are lists of Symbols:



words = cut, was, saw, clear, sharp, keen, tree, these;

Symbol /@ GeneralUtilities`ToTitleCase[ToString /@ words]



Cut, Was, Saw, Clear, Sharp, Keen, Tree, These







share|improve this answer





























    up vote
    7
    down vote













    Could also use Capitalize:



    Capitalize["cut", "was", "saw", "clear", "sharp", "keen", "tree", "these"]



    "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"







    share|improve this answer




















      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180335%2fstring-list-manipulation%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote



      accepted










      If the input and the desired output are lists of Strings:



      strings = "cut", "was", "saw", "clear", "sharp", "keen", "tree", "these";

      GeneralUtilities`ToTitleCase[strings]



      "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




      Alternatively, you can use StringReplace:



      StringReplace[strings, WordBoundary ~~ a_ :> ToUpperCase[a]]



      "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




      If the input and desired output are lists of Symbols:



      words = cut, was, saw, clear, sharp, keen, tree, these;

      Symbol /@ GeneralUtilities`ToTitleCase[ToString /@ words]



      Cut, Was, Saw, Clear, Sharp, Keen, Tree, These







      share|improve this answer


























        up vote
        3
        down vote



        accepted










        If the input and the desired output are lists of Strings:



        strings = "cut", "was", "saw", "clear", "sharp", "keen", "tree", "these";

        GeneralUtilities`ToTitleCase[strings]



        "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




        Alternatively, you can use StringReplace:



        StringReplace[strings, WordBoundary ~~ a_ :> ToUpperCase[a]]



        "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




        If the input and desired output are lists of Symbols:



        words = cut, was, saw, clear, sharp, keen, tree, these;

        Symbol /@ GeneralUtilities`ToTitleCase[ToString /@ words]



        Cut, Was, Saw, Clear, Sharp, Keen, Tree, These







        share|improve this answer
























          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          If the input and the desired output are lists of Strings:



          strings = "cut", "was", "saw", "clear", "sharp", "keen", "tree", "these";

          GeneralUtilities`ToTitleCase[strings]



          "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




          Alternatively, you can use StringReplace:



          StringReplace[strings, WordBoundary ~~ a_ :> ToUpperCase[a]]



          "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




          If the input and desired output are lists of Symbols:



          words = cut, was, saw, clear, sharp, keen, tree, these;

          Symbol /@ GeneralUtilities`ToTitleCase[ToString /@ words]



          Cut, Was, Saw, Clear, Sharp, Keen, Tree, These







          share|improve this answer














          If the input and the desired output are lists of Strings:



          strings = "cut", "was", "saw", "clear", "sharp", "keen", "tree", "these";

          GeneralUtilities`ToTitleCase[strings]



          "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




          Alternatively, you can use StringReplace:



          StringReplace[strings, WordBoundary ~~ a_ :> ToUpperCase[a]]



          "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"




          If the input and desired output are lists of Symbols:



          words = cut, was, saw, clear, sharp, keen, tree, these;

          Symbol /@ GeneralUtilities`ToTitleCase[ToString /@ words]



          Cut, Was, Saw, Clear, Sharp, Keen, Tree, These








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 21 at 5:41

























          answered Aug 21 at 5:12









          kglr

          161k8185384




          161k8185384




















              up vote
              7
              down vote













              Could also use Capitalize:



              Capitalize["cut", "was", "saw", "clear", "sharp", "keen", "tree", "these"]



              "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"







              share|improve this answer
























                up vote
                7
                down vote













                Could also use Capitalize:



                Capitalize["cut", "was", "saw", "clear", "sharp", "keen", "tree", "these"]



                "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"







                share|improve this answer






















                  up vote
                  7
                  down vote










                  up vote
                  7
                  down vote









                  Could also use Capitalize:



                  Capitalize["cut", "was", "saw", "clear", "sharp", "keen", "tree", "these"]



                  "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"







                  share|improve this answer












                  Could also use Capitalize:



                  Capitalize["cut", "was", "saw", "clear", "sharp", "keen", "tree", "these"]



                  "Cut", "Was", "Saw", "Clear", "Sharp", "Keen", "Tree", "These"








                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 21 at 5:54









                  Carl Woll

                  57.8k273150




                  57.8k273150



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180335%2fstring-list-manipulation%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Christian Cage

                      How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?