Find non-case sensitive string in a mixed list of elements? The Next CEO of Stack OverflowBuilding a list recursive with one or more argumentsReturn Functions from parallel execution of moduleFast method to select matrix elements based on a vector of positionsIssue with very large lists in MathematicaFaster position list construction from a “take instructions” listConvert elements of list to stringAdding a collection of neighbors to points in a list, concatenating strings, parallelization/optimizing run-time?Get sublists by pattern?Obtaining the position in a list where the i^th element is bigger than the (i+1)^th elementExtract all instances of variables matching a pattern?

Do I need to write [sic] when a number is less than 10 but isn't written out?

Why, when going from special to general relativity, do we just replace partial derivatives with covariant derivatives?

Easy to read palindrome checker

How many extra stops do monopods offer for tele photographs?

Why the difference in type-inference over the as-pattern in two similar function definitions?

Won the lottery - how do I keep the money?

How to count occurrences of text in a file?

What does "Its cash flow is deeply negative" mean?

Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Find non-case sensitive string in a mixed list of elements?

Are police here, aren't itthey?

Unclear about dynamic binding

Powershell. How to parse gci Name?

What connection does MS Office have to Netscape Navigator?

Why do remote US companies require working in the US?

Why do airplanes bank sharply to the right after air-to-air refueling?

Should I tutor a student who I know has cheated on their homework?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

Is there a difference between "Fahrstuhl" and "Aufzug"

What steps are necessary to read a Modern SSD in Medieval Europe?

Solving system of ODEs with extra parameter

Math-accent symbol over parentheses enclosing accented symbol (amsmath)

Why is my new battery behaving weirdly?



Find non-case sensitive string in a mixed list of elements?



The Next CEO of Stack OverflowBuilding a list recursive with one or more argumentsReturn Functions from parallel execution of moduleFast method to select matrix elements based on a vector of positionsIssue with very large lists in MathematicaFaster position list construction from a “take instructions” listConvert elements of list to stringAdding a collection of neighbors to points in a list, concatenating strings, parallelization/optimizing run-time?Get sublists by pattern?Obtaining the position in a list where the i^th element is bigger than the (i+1)^th elementExtract all instances of variables matching a pattern?










2












$begingroup$


Consider an example list with mixed element types, e.g.:



list = 1.234 , a[2] , "Abc" , 4/5 , "acb" ;


I would like to have a function that finds the position of a string, without regard to upper or lower characters, e.g.:



findPosition[list,"abc"]



3,1




Is there a function like that in Mathematica? Or maybe one can implement it with efficient performance?



EDIT:



My current workaround is:



findPosition[list_,str_]:=Position[list/.x_String:>ToLowerCase[x],ToLowerCase[str]]









share|improve this question











$endgroup$
















    2












    $begingroup$


    Consider an example list with mixed element types, e.g.:



    list = 1.234 , a[2] , "Abc" , 4/5 , "acb" ;


    I would like to have a function that finds the position of a string, without regard to upper or lower characters, e.g.:



    findPosition[list,"abc"]



    3,1




    Is there a function like that in Mathematica? Or maybe one can implement it with efficient performance?



    EDIT:



    My current workaround is:



    findPosition[list_,str_]:=Position[list/.x_String:>ToLowerCase[x],ToLowerCase[str]]









    share|improve this question











    $endgroup$














      2












      2








      2





      $begingroup$


      Consider an example list with mixed element types, e.g.:



      list = 1.234 , a[2] , "Abc" , 4/5 , "acb" ;


      I would like to have a function that finds the position of a string, without regard to upper or lower characters, e.g.:



      findPosition[list,"abc"]



      3,1




      Is there a function like that in Mathematica? Or maybe one can implement it with efficient performance?



      EDIT:



      My current workaround is:



      findPosition[list_,str_]:=Position[list/.x_String:>ToLowerCase[x],ToLowerCase[str]]









      share|improve this question











      $endgroup$




      Consider an example list with mixed element types, e.g.:



      list = 1.234 , a[2] , "Abc" , 4/5 , "acb" ;


      I would like to have a function that finds the position of a string, without regard to upper or lower characters, e.g.:



      findPosition[list,"abc"]



      3,1




      Is there a function like that in Mathematica? Or maybe one can implement it with efficient performance?



      EDIT:



      My current workaround is:



      findPosition[list_,str_]:=Position[list/.x_String:>ToLowerCase[x],ToLowerCase[str]]






      list-manipulation function-construction searching






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 hours ago







      Kagaratsch

















      asked 3 hours ago









      KagaratschKagaratsch

      4,77631348




      4,77631348




















          3 Answers
          3






          active

          oldest

          votes


















          2












          $begingroup$

          Position[list, s_String /; ToLowerCase[s] == "abc"]



          3, 1




          or



          Position[list, s_String?(EqualTo["abc"]@*ToLowerCase)]





          share|improve this answer









          $endgroup$












          • $begingroup$
            I like how this does not need to make substitutions in list itself to search it!
            $endgroup$
            – Kagaratsch
            3 hours ago






          • 1




            $begingroup$
            Position[ToLowerCase[list], "abc"] also works.
            $endgroup$
            – C. E.
            2 hours ago



















          1












          $begingroup$

          Note that ToLowerCase does not evaluate if the input is not a string, but it is Listable, so it will thread over your list:



          list = 1.234, a[2], "Abc", 4/5, "acb";
          ToLowerCase[list]

          (* Out: ToLowerCase[1.234], ToLowerCase[a[2]], "abc", ToLowerCase[4/5], "acb" *)


          That should not bother you though; it certainly does not bother Position:



          Position[ToLowerCase[list], "abc"]
          (* Out: 3, 1 *)





          share|improve this answer









          $endgroup$




















            0












            $begingroup$

            Recall that StringMatchQ[] has the IgnoreCase option:



            Position[1.234, a[2], "Abc", 4/5, "acb",
            s_String /; StringMatchQ[s, "abc", IgnoreCase -> True]]
            3, 1





            share|improve this answer











            $endgroup$













              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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              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%2f194280%2ffind-non-case-sensitive-string-in-a-mixed-list-of-elements%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2












              $begingroup$

              Position[list, s_String /; ToLowerCase[s] == "abc"]



              3, 1




              or



              Position[list, s_String?(EqualTo["abc"]@*ToLowerCase)]





              share|improve this answer









              $endgroup$












              • $begingroup$
                I like how this does not need to make substitutions in list itself to search it!
                $endgroup$
                – Kagaratsch
                3 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                2 hours ago
















              2












              $begingroup$

              Position[list, s_String /; ToLowerCase[s] == "abc"]



              3, 1




              or



              Position[list, s_String?(EqualTo["abc"]@*ToLowerCase)]





              share|improve this answer









              $endgroup$












              • $begingroup$
                I like how this does not need to make substitutions in list itself to search it!
                $endgroup$
                – Kagaratsch
                3 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                2 hours ago














              2












              2








              2





              $begingroup$

              Position[list, s_String /; ToLowerCase[s] == "abc"]



              3, 1




              or



              Position[list, s_String?(EqualTo["abc"]@*ToLowerCase)]





              share|improve this answer









              $endgroup$



              Position[list, s_String /; ToLowerCase[s] == "abc"]



              3, 1




              or



              Position[list, s_String?(EqualTo["abc"]@*ToLowerCase)]






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 3 hours ago









              Henrik SchumacherHenrik Schumacher

              58.6k581162




              58.6k581162











              • $begingroup$
                I like how this does not need to make substitutions in list itself to search it!
                $endgroup$
                – Kagaratsch
                3 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                2 hours ago

















              • $begingroup$
                I like how this does not need to make substitutions in list itself to search it!
                $endgroup$
                – Kagaratsch
                3 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                2 hours ago
















              $begingroup$
              I like how this does not need to make substitutions in list itself to search it!
              $endgroup$
              – Kagaratsch
              3 hours ago




              $begingroup$
              I like how this does not need to make substitutions in list itself to search it!
              $endgroup$
              – Kagaratsch
              3 hours ago




              1




              1




              $begingroup$
              Position[ToLowerCase[list], "abc"] also works.
              $endgroup$
              – C. E.
              2 hours ago





              $begingroup$
              Position[ToLowerCase[list], "abc"] also works.
              $endgroup$
              – C. E.
              2 hours ago












              1












              $begingroup$

              Note that ToLowerCase does not evaluate if the input is not a string, but it is Listable, so it will thread over your list:



              list = 1.234, a[2], "Abc", 4/5, "acb";
              ToLowerCase[list]

              (* Out: ToLowerCase[1.234], ToLowerCase[a[2]], "abc", ToLowerCase[4/5], "acb" *)


              That should not bother you though; it certainly does not bother Position:



              Position[ToLowerCase[list], "abc"]
              (* Out: 3, 1 *)





              share|improve this answer









              $endgroup$

















                1












                $begingroup$

                Note that ToLowerCase does not evaluate if the input is not a string, but it is Listable, so it will thread over your list:



                list = 1.234, a[2], "Abc", 4/5, "acb";
                ToLowerCase[list]

                (* Out: ToLowerCase[1.234], ToLowerCase[a[2]], "abc", ToLowerCase[4/5], "acb" *)


                That should not bother you though; it certainly does not bother Position:



                Position[ToLowerCase[list], "abc"]
                (* Out: 3, 1 *)





                share|improve this answer









                $endgroup$















                  1












                  1








                  1





                  $begingroup$

                  Note that ToLowerCase does not evaluate if the input is not a string, but it is Listable, so it will thread over your list:



                  list = 1.234, a[2], "Abc", 4/5, "acb";
                  ToLowerCase[list]

                  (* Out: ToLowerCase[1.234], ToLowerCase[a[2]], "abc", ToLowerCase[4/5], "acb" *)


                  That should not bother you though; it certainly does not bother Position:



                  Position[ToLowerCase[list], "abc"]
                  (* Out: 3, 1 *)





                  share|improve this answer









                  $endgroup$



                  Note that ToLowerCase does not evaluate if the input is not a string, but it is Listable, so it will thread over your list:



                  list = 1.234, a[2], "Abc", 4/5, "acb";
                  ToLowerCase[list]

                  (* Out: ToLowerCase[1.234], ToLowerCase[a[2]], "abc", ToLowerCase[4/5], "acb" *)


                  That should not bother you though; it certainly does not bother Position:



                  Position[ToLowerCase[list], "abc"]
                  (* Out: 3, 1 *)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  MarcoBMarcoB

                  38.2k556114




                  38.2k556114





















                      0












                      $begingroup$

                      Recall that StringMatchQ[] has the IgnoreCase option:



                      Position[1.234, a[2], "Abc", 4/5, "acb",
                      s_String /; StringMatchQ[s, "abc", IgnoreCase -> True]]
                      3, 1





                      share|improve this answer











                      $endgroup$

















                        0












                        $begingroup$

                        Recall that StringMatchQ[] has the IgnoreCase option:



                        Position[1.234, a[2], "Abc", 4/5, "acb",
                        s_String /; StringMatchQ[s, "abc", IgnoreCase -> True]]
                        3, 1





                        share|improve this answer











                        $endgroup$















                          0












                          0








                          0





                          $begingroup$

                          Recall that StringMatchQ[] has the IgnoreCase option:



                          Position[1.234, a[2], "Abc", 4/5, "acb",
                          s_String /; StringMatchQ[s, "abc", IgnoreCase -> True]]
                          3, 1





                          share|improve this answer











                          $endgroup$



                          Recall that StringMatchQ[] has the IgnoreCase option:



                          Position[1.234, a[2], "Abc", 4/5, "acb",
                          s_String /; StringMatchQ[s, "abc", IgnoreCase -> True]]
                          3, 1






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          answered 30 mins ago


























                          community wiki





                          J. M. is slightly pensive




























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Mathematica Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194280%2ffind-non-case-sensitive-string-in-a-mixed-list-of-elements%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Reverse int within the 32-bit signed integer range: [−2^31, 2^31 − 1]Combining two 32-bit integers into one 64-bit integerDetermine if an int is within rangeLossy packing 32 bit integer to 16 bitComputing the square root of a 64-bit integerKeeping integer addition within boundsSafe multiplication of two 64-bit signed integersLeetcode 10: Regular Expression MatchingSigned integer-to-ascii x86_64 assembler macroReverse the digits of an Integer“Add two numbers given in reverse order from a linked list”

                              Category:Fedor von Bock Media in category "Fedor von Bock"Navigation menuUpload mediaISNI: 0000 0000 5511 3417VIAF ID: 24712551GND ID: 119294796Library of Congress authority ID: n96068363BnF ID: 12534305fSUDOC authorities ID: 034604189Open Library ID: OL338253ANKCR AUT ID: jn19990000869National Library of Israel ID: 000514068National Thesaurus for Author Names ID: 341574317ReasonatorScholiaStatistics

                              Kiel Indholdsfortegnelse Historie | Transport og færgeforbindelser | Sejlsport og anden sport | Kultur | Kendte personer fra Kiel | Noter | Litteratur | Eksterne henvisninger | Navigationsmenuwww.kiel.de54°19′31″N 10°8′26″Ø / 54.32528°N 10.14056°Ø / 54.32528; 10.14056Oberbürgermeister Dr. Ulf Kämpferwww.statistik-nord.deDen danske Stats StatistikKiels hjemmesiderrrWorldCat312794080n790547494030481-4