Filename match with Python regexCalling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Regular expression to match a line that doesn't contain a word?How to get the current time in PythonRegEx match open tags except XHTML self-contained tagsDoes Python have a string 'contains' substring method?

Finding files for which a command fails

Calculate Levenshtein distance between two strings in Python

Does a dangling wire really electrocute me if I'm standing in water?

Are white and non-white police officers equally likely to kill black suspects?

Travelling to Edinburgh from India

Is there a way to make member function NOT callable from constructor?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Lied on resume at previous job

I am not able to install anything in ubuntu

Extreme, but not acceptable situation and I can't start the work tomorrow morning

How would photo IDs work for shapeshifters?

Some basic questions on halt and move in Turing machines

How to make payment on the internet without leaving a money trail?

How can I add custom success page

Where to refill my bottle in India?

Denied boarding due to overcrowding, Sparpreis ticket. What are my rights?

Add an angle to a sphere

How do you conduct xenoanthropology after first contact?

Unbreakable Formation vs. Cry of the Carnarium

Is this food a bread or a loaf?

Eliminate empty elements from a list with a specific pattern

What does "enim et" mean?

What is GPS' 19 year rollover and does it present a cybersecurity issue?

Pristine Bit Checking



Filename match with Python regex


Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Regular expression to match a line that doesn't contain a word?How to get the current time in PythonRegEx match open tags except XHTML self-contained tagsDoes Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I have a text file scrapped from my email which contains 1 attachment/mail. The attachment is present under different names with totally different formats, ex.:



filename="John_wheeler 11041997 resume.pdf";
filename="Kujal_newResume(1).pdf";
filename=JohnKrasinski_Resume.pdf


My question is: is there any way to find a RegEx pattern that would start searching from filename= and go until the dot character (that separates from file extension)? Getting file extension would be next task, but I can hold that for now. Please help me figure this out.










share|improve this question



















  • 1





    Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

    – Yusufsn
    Mar 8 at 7:13


















-1















I have a text file scrapped from my email which contains 1 attachment/mail. The attachment is present under different names with totally different formats, ex.:



filename="John_wheeler 11041997 resume.pdf";
filename="Kujal_newResume(1).pdf";
filename=JohnKrasinski_Resume.pdf


My question is: is there any way to find a RegEx pattern that would start searching from filename= and go until the dot character (that separates from file extension)? Getting file extension would be next task, but I can hold that for now. Please help me figure this out.










share|improve this question



















  • 1





    Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

    – Yusufsn
    Mar 8 at 7:13














-1












-1








-1








I have a text file scrapped from my email which contains 1 attachment/mail. The attachment is present under different names with totally different formats, ex.:



filename="John_wheeler 11041997 resume.pdf";
filename="Kujal_newResume(1).pdf";
filename=JohnKrasinski_Resume.pdf


My question is: is there any way to find a RegEx pattern that would start searching from filename= and go until the dot character (that separates from file extension)? Getting file extension would be next task, but I can hold that for now. Please help me figure this out.










share|improve this question
















I have a text file scrapped from my email which contains 1 attachment/mail. The attachment is present under different names with totally different formats, ex.:



filename="John_wheeler 11041997 resume.pdf";
filename="Kujal_newResume(1).pdf";
filename=JohnKrasinski_Resume.pdf


My question is: is there any way to find a RegEx pattern that would start searching from filename= and go until the dot character (that separates from file extension)? Getting file extension would be next task, but I can hold that for now. Please help me figure this out.







python regex python-3.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 8:13









Michał Turczyn

16.2k132241




16.2k132241










asked Mar 8 at 7:07









Srinath RadhakrishnanSrinath Radhakrishnan

42




42







  • 1





    Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

    – Yusufsn
    Mar 8 at 7:13













  • 1





    Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

    – Yusufsn
    Mar 8 at 7:13








1




1





Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

– Yusufsn
Mar 8 at 7:13






Your question is unclear. Please provide the data/input you have, the code that you have tried, the expected output and the error you got.

– Yusufsn
Mar 8 at 7:13













3 Answers
3






active

oldest

votes


















1














You could try this pattern: filename="?([^.]+)



It assumes that dot separates filename from extension.



Explanation:



filename="? - match filename= literally and tehn match 0 or 1 apostrophe "



([^.]+) - match one or more characters that is not a dot (match everything until dot) and store it in capturing group



Your desired filename will be stored in capturing group.



Demo



EXTRA: to capture also file extension, you could use such pattern: filename="?([^.]+).([^";]+)



Additional thing here is .([^";]+): matches dot literally with .. Then it matches one or more characters other than " or ; with pattern [^";]+ and stores it in second capturing gropup.



Another demo






share|improve this answer
































    0














    How about the following:



    (?:filename=)([^.]*).(w*)


    This REGEX returns different groups containing the different elements you're interested in.






    share|improve this answer






























      0














      I'm not sure the output you expect. But this may help. RegexDemo



      (?<=filename=)["]?(w.*[.].*)(?<=w)["]?


      Or if you want to ignore the file extension:



      (?<=filename=)["]?(w.*)[.]





      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        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: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        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%2fstackoverflow.com%2fquestions%2f55058331%2ffilename-match-with-python-regex%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









        1














        You could try this pattern: filename="?([^.]+)



        It assumes that dot separates filename from extension.



        Explanation:



        filename="? - match filename= literally and tehn match 0 or 1 apostrophe "



        ([^.]+) - match one or more characters that is not a dot (match everything until dot) and store it in capturing group



        Your desired filename will be stored in capturing group.



        Demo



        EXTRA: to capture also file extension, you could use such pattern: filename="?([^.]+).([^";]+)



        Additional thing here is .([^";]+): matches dot literally with .. Then it matches one or more characters other than " or ; with pattern [^";]+ and stores it in second capturing gropup.



        Another demo






        share|improve this answer





























          1














          You could try this pattern: filename="?([^.]+)



          It assumes that dot separates filename from extension.



          Explanation:



          filename="? - match filename= literally and tehn match 0 or 1 apostrophe "



          ([^.]+) - match one or more characters that is not a dot (match everything until dot) and store it in capturing group



          Your desired filename will be stored in capturing group.



          Demo



          EXTRA: to capture also file extension, you could use such pattern: filename="?([^.]+).([^";]+)



          Additional thing here is .([^";]+): matches dot literally with .. Then it matches one or more characters other than " or ; with pattern [^";]+ and stores it in second capturing gropup.



          Another demo






          share|improve this answer



























            1












            1








            1







            You could try this pattern: filename="?([^.]+)



            It assumes that dot separates filename from extension.



            Explanation:



            filename="? - match filename= literally and tehn match 0 or 1 apostrophe "



            ([^.]+) - match one or more characters that is not a dot (match everything until dot) and store it in capturing group



            Your desired filename will be stored in capturing group.



            Demo



            EXTRA: to capture also file extension, you could use such pattern: filename="?([^.]+).([^";]+)



            Additional thing here is .([^";]+): matches dot literally with .. Then it matches one or more characters other than " or ; with pattern [^";]+ and stores it in second capturing gropup.



            Another demo






            share|improve this answer















            You could try this pattern: filename="?([^.]+)



            It assumes that dot separates filename from extension.



            Explanation:



            filename="? - match filename= literally and tehn match 0 or 1 apostrophe "



            ([^.]+) - match one or more characters that is not a dot (match everything until dot) and store it in capturing group



            Your desired filename will be stored in capturing group.



            Demo



            EXTRA: to capture also file extension, you could use such pattern: filename="?([^.]+).([^";]+)



            Additional thing here is .([^";]+): matches dot literally with .. Then it matches one or more characters other than " or ; with pattern [^";]+ and stores it in second capturing gropup.



            Another demo







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 8 at 8:20

























            answered Mar 8 at 8:12









            Michał TurczynMichał Turczyn

            16.2k132241




            16.2k132241























                0














                How about the following:



                (?:filename=)([^.]*).(w*)


                This REGEX returns different groups containing the different elements you're interested in.






                share|improve this answer



























                  0














                  How about the following:



                  (?:filename=)([^.]*).(w*)


                  This REGEX returns different groups containing the different elements you're interested in.






                  share|improve this answer

























                    0












                    0








                    0







                    How about the following:



                    (?:filename=)([^.]*).(w*)


                    This REGEX returns different groups containing the different elements you're interested in.






                    share|improve this answer













                    How about the following:



                    (?:filename=)([^.]*).(w*)


                    This REGEX returns different groups containing the different elements you're interested in.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 8 at 7:15









                    tk78tk78

                    547310




                    547310





















                        0














                        I'm not sure the output you expect. But this may help. RegexDemo



                        (?<=filename=)["]?(w.*[.].*)(?<=w)["]?


                        Or if you want to ignore the file extension:



                        (?<=filename=)["]?(w.*)[.]





                        share|improve this answer



























                          0














                          I'm not sure the output you expect. But this may help. RegexDemo



                          (?<=filename=)["]?(w.*[.].*)(?<=w)["]?


                          Or if you want to ignore the file extension:



                          (?<=filename=)["]?(w.*)[.]





                          share|improve this answer

























                            0












                            0








                            0







                            I'm not sure the output you expect. But this may help. RegexDemo



                            (?<=filename=)["]?(w.*[.].*)(?<=w)["]?


                            Or if you want to ignore the file extension:



                            (?<=filename=)["]?(w.*)[.]





                            share|improve this answer













                            I'm not sure the output you expect. But this may help. RegexDemo



                            (?<=filename=)["]?(w.*[.].*)(?<=w)["]?


                            Or if you want to ignore the file extension:



                            (?<=filename=)["]?(w.*)[.]






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 8 at 7:26









                            YusufsnYusufsn

                            574215




                            574215



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • 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.

                                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%2fstackoverflow.com%2fquestions%2f55058331%2ffilename-match-with-python-regex%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

                                AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                                Алба-Юлія

                                Захаров Федір Захарович