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?

Why didn't Khan get resurrected in the Genesis Explosion?

What happened in Rome, when the western empire "fell"?

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

What did we know about the Kessel run before the prequels?

Rotate a column

Would a completely good Muggle be able to use a wand?

What is the value of α and β in a triangle?

Why this way of making earth uninhabitable in Interstellar?

Axiom Schema vs Axiom

No sign flipping while figuring out the emf of voltaic cell?

WOW air has ceased operation, can I get my tickets refunded?

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

How to get from Geneva Airport to Metabief?

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

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Bartok - Syncopation (1): Meaning of notes in between Grand Staff

Chain wire methods together in Lightning Web Components

Writing differences on a blackboard

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

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

Is there a way to save my career from absolute disaster?

How to place nodes around a circle from some initial angle?

Does Germany produce more waste than the US?

The exact meaning of 'Mom made me a sandwich'



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 2 hours ago







      Kagaratsch

















      asked 2 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
            2 hours ago






          • 1




            $begingroup$
            Position[ToLowerCase[list], "abc"] also works.
            $endgroup$
            – C. E.
            1 hour 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











            $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
                2 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                1 hour 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
                2 hours ago






              • 1




                $begingroup$
                Position[ToLowerCase[list], "abc"] also works.
                $endgroup$
                – C. E.
                1 hour 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 2 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
                2 hours ago






              • 1




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

















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






              • 1




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
















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




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




              1




              1




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





              $begingroup$
              Position[ToLowerCase[list], "abc"] also works.
              $endgroup$
              – C. E.
              1 hour 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 41 mins 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











                      $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











                        $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











                          $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













                          share


                          share








                          answered 7 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

                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                              Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367