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?

What does it mean 'exit 1' for a job status after rclone sync

Why did Batya get tzaraat?

"Eavesdropping" vs "Listen in on"

Why did the Drakh emissary look so blurred in S04:E11 "Lines of Communication"?

What did the word "leisure" mean in late 18th Century usage?

How does a dynamic QR code work?

Percent Dissociated from Titration Curve

About implicitly convert type 'int' to 'char', why it is different between `s[i] += s[j]` and `s[i] = s[i]+s[j] `

Salesforce opportunity stages

Man transported from Alternate World into ours by a Neutrino Detector

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Is it a bad idea to plug the other end of ESD strap to wall ground?

What happens if you break a law in another country outside of that country?

How can I prove that a state of equilibrium is unstable?

Words hidden in my phone number

Find the majority element, which appears more than half the time

It it possible to avoid kiwi.com's automatic online check-in and instead do it manually by yourself?

Is the offspring between a demon and a celestial possible? If so what is it called and is it in a book somewhere?

My boss doesn't want me to have a side project

Incomplete cube

How can I separate the number from the unit in argument?

Ising model simulation

Prodigo = pro + ago?

Planeswalker Ability and Death Timing



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?










3












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
















    3












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














      3












      3








      3





      $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 days ago







      Kagaratsch

















      asked 2 days ago









      KagaratschKagaratsch

      4,77931348




      4,77931348




















          3 Answers
          3






          active

          oldest

          votes


















          2












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








          • 1




            $begingroup$
            Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
            $endgroup$
            – Kagaratsch
            yesterday


















          3












          $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 days ago






          • 2




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











          • $begingroup$
            The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
            $endgroup$
            – Henrik Schumacher
            yesterday


















          3












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













            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$

            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$








            • 1




              $begingroup$
              Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
              $endgroup$
              – Kagaratsch
              yesterday















            2












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








            • 1




              $begingroup$
              Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
              $endgroup$
              – Kagaratsch
              yesterday













            2












            2








            2





            $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 yesterday


























            community wiki





            J. M. is slightly pensive








            • 1




              $begingroup$
              Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
              $endgroup$
              – Kagaratsch
              yesterday












            • 1




              $begingroup$
              Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
              $endgroup$
              – Kagaratsch
              yesterday







            1




            1




            $begingroup$
            Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
            $endgroup$
            – Kagaratsch
            yesterday




            $begingroup$
            Decided to go with this answer after all, since it is minimal, as all it does is a query -- no operations on the data.
            $endgroup$
            – Kagaratsch
            yesterday











            3












            $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 days ago






            • 2




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











            • $begingroup$
              The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
              $endgroup$
              – Henrik Schumacher
              yesterday















            3












            $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 days ago






            • 2




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











            • $begingroup$
              The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
              $endgroup$
              – Henrik Schumacher
              yesterday













            3












            3








            3





            $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 days ago









            Henrik SchumacherHenrik Schumacher

            58.7k581162




            58.7k581162











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






            • 2




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











            • $begingroup$
              The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
              $endgroup$
              – Henrik Schumacher
              yesterday
















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






            • 2




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











            • $begingroup$
              The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
              $endgroup$
              – Henrik Schumacher
              yesterday















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




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




            2




            2




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





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













            $begingroup$
            The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
            $endgroup$
            – Henrik Schumacher
            yesterday




            $begingroup$
            The rationale behind using a _String pattern is to pre-filter with a very inexpensive test: This ensures that only few expressions are actually fed to ToLowerCase.
            $endgroup$
            – Henrik Schumacher
            yesterday











            3












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

















              3












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















                3












                3








                3





                $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 yesterday









                MarcoBMarcoB

                38.4k556115




                38.4k556115



























                    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

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Why did Thanos need his ship to help him in the battle scene?Which actor plays Thanos in the Avengers mid-credits scene?Are there economic implications portrayed in comics where the buildings and cities are ruined almost daily?Old X-Men comic where team travels to alien world with a ring-like sun that needs recharging?Why does Ego need help sleeping?Is there an objective answer to who “the strongest Avenger” is?How did Banner get unstuck?Why did Thanos get hit?How did Thanos (or anyone) know the Infinity Stones would give him this power?Did Thanos leave Eitri alive for his after-sales service?In Avengers 1, why does Thanos need Loki?