Make character in tag uppercase and remove tag











up vote
-3
down vote

favorite












How to make a character between a tag uppercase?



For example I have this string:



string = "<big>t<big>his should be <big>u<big>ppercase"


Should result in:



This should be Uppercase









share|improve this question




















  • 1




    I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
    – Anton vBR
    yesterday












  • is <big> even a real tag?
    – Paritosh Singh
    yesterday










  • It's not a real tag, just for example.
    – rw026
    yesterday










  • Normally you'd expect the closing tag to be </big>
    – khelwood
    yesterday










  • Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
    – Paritosh Singh
    yesterday















up vote
-3
down vote

favorite












How to make a character between a tag uppercase?



For example I have this string:



string = "<big>t<big>his should be <big>u<big>ppercase"


Should result in:



This should be Uppercase









share|improve this question




















  • 1




    I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
    – Anton vBR
    yesterday












  • is <big> even a real tag?
    – Paritosh Singh
    yesterday










  • It's not a real tag, just for example.
    – rw026
    yesterday










  • Normally you'd expect the closing tag to be </big>
    – khelwood
    yesterday










  • Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
    – Paritosh Singh
    yesterday













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











How to make a character between a tag uppercase?



For example I have this string:



string = "<big>t<big>his should be <big>u<big>ppercase"


Should result in:



This should be Uppercase









share|improve this question















How to make a character between a tag uppercase?



For example I have this string:



string = "<big>t<big>his should be <big>u<big>ppercase"


Should result in:



This should be Uppercase






python string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked yesterday









rw026

155




155








  • 1




    I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
    – Anton vBR
    yesterday












  • is <big> even a real tag?
    – Paritosh Singh
    yesterday










  • It's not a real tag, just for example.
    – rw026
    yesterday










  • Normally you'd expect the closing tag to be </big>
    – khelwood
    yesterday










  • Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
    – Paritosh Singh
    yesterday














  • 1




    I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
    – Anton vBR
    yesterday












  • is <big> even a real tag?
    – Paritosh Singh
    yesterday










  • It's not a real tag, just for example.
    – rw026
    yesterday










  • Normally you'd expect the closing tag to be </big>
    – khelwood
    yesterday










  • Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
    – Paritosh Singh
    yesterday








1




1




I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
– Anton vBR
yesterday






I'd have a look at XML parsing. Maybe this can help you out: docs.python.org/3/library/xml.etree.elementtree.html. Another thing: remember that the variable name str is reserved!!
– Anton vBR
yesterday














is <big> even a real tag?
– Paritosh Singh
yesterday




is <big> even a real tag?
– Paritosh Singh
yesterday












It's not a real tag, just for example.
– rw026
yesterday




It's not a real tag, just for example.
– rw026
yesterday












Normally you'd expect the closing tag to be </big>
– khelwood
yesterday




Normally you'd expect the closing tag to be </big>
– khelwood
yesterday












Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday




Just a heads up, make sure this is not an XY Problem If you need to deal with actual xml tags, look at Anton's comment.
– Paritosh Singh
yesterday












3 Answers
3






active

oldest

votes

















up vote
1
down vote













Constantly as longest as there's < big> in txt remove tags and uppercase the text between them



def up(x):
idx1 = x.index('<big>')
idx2 = x.index('<big>', idx1+1)

new_x = x[:idx1]
new_x += x[idx1+5: idx2].upper()
new_x += x[idx2+5:]

return new_x

txt = "<big>t<big>his should be <big>u<big>ppercase"
while '<big>' in txt:
txt = up(txt)

print(txt) # This should be Uppercase





share|improve this answer






























    up vote
    1
    down vote













    Try this:



    import re

    s="<big>t<big>his should be <big>u<big>ppercase"

    result = re.finditer('<big>(.)<big>', s)

    for i in result:
    s = s.replace(i.group(0), i.group(1).upper())


    Note:




    Do not use str as a name of a variable. str is predefined in python.







    share|improve this answer




























      up vote
      0
      down vote













      Those don't look like real xml tags. But assuming the number of <big> tags are used correctly, you can split it by tag and apply upper() to strings between.



      text = "<big>t<big>his should be <big>u<big>ppercase"

      split_str = text.split('<big>')
      result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])





      share|improve this answer








      New contributor




      boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.


















        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',
        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%2f53238506%2fmake-character-in-tag-uppercase-and-remove-tag%23new-answer', 'question_page');
        }
        );

        Post as a guest
































        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1
        down vote













        Constantly as longest as there's < big> in txt remove tags and uppercase the text between them



        def up(x):
        idx1 = x.index('<big>')
        idx2 = x.index('<big>', idx1+1)

        new_x = x[:idx1]
        new_x += x[idx1+5: idx2].upper()
        new_x += x[idx2+5:]

        return new_x

        txt = "<big>t<big>his should be <big>u<big>ppercase"
        while '<big>' in txt:
        txt = up(txt)

        print(txt) # This should be Uppercase





        share|improve this answer



























          up vote
          1
          down vote













          Constantly as longest as there's < big> in txt remove tags and uppercase the text between them



          def up(x):
          idx1 = x.index('<big>')
          idx2 = x.index('<big>', idx1+1)

          new_x = x[:idx1]
          new_x += x[idx1+5: idx2].upper()
          new_x += x[idx2+5:]

          return new_x

          txt = "<big>t<big>his should be <big>u<big>ppercase"
          while '<big>' in txt:
          txt = up(txt)

          print(txt) # This should be Uppercase





          share|improve this answer

























            up vote
            1
            down vote










            up vote
            1
            down vote









            Constantly as longest as there's < big> in txt remove tags and uppercase the text between them



            def up(x):
            idx1 = x.index('<big>')
            idx2 = x.index('<big>', idx1+1)

            new_x = x[:idx1]
            new_x += x[idx1+5: idx2].upper()
            new_x += x[idx2+5:]

            return new_x

            txt = "<big>t<big>his should be <big>u<big>ppercase"
            while '<big>' in txt:
            txt = up(txt)

            print(txt) # This should be Uppercase





            share|improve this answer














            Constantly as longest as there's < big> in txt remove tags and uppercase the text between them



            def up(x):
            idx1 = x.index('<big>')
            idx2 = x.index('<big>', idx1+1)

            new_x = x[:idx1]
            new_x += x[idx1+5: idx2].upper()
            new_x += x[idx2+5:]

            return new_x

            txt = "<big>t<big>his should be <big>u<big>ppercase"
            while '<big>' in txt:
            txt = up(txt)

            print(txt) # This should be Uppercase






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited yesterday

























            answered yesterday









            Looioe

            845




            845
























                up vote
                1
                down vote













                Try this:



                import re

                s="<big>t<big>his should be <big>u<big>ppercase"

                result = re.finditer('<big>(.)<big>', s)

                for i in result:
                s = s.replace(i.group(0), i.group(1).upper())


                Note:




                Do not use str as a name of a variable. str is predefined in python.







                share|improve this answer

























                  up vote
                  1
                  down vote













                  Try this:



                  import re

                  s="<big>t<big>his should be <big>u<big>ppercase"

                  result = re.finditer('<big>(.)<big>', s)

                  for i in result:
                  s = s.replace(i.group(0), i.group(1).upper())


                  Note:




                  Do not use str as a name of a variable. str is predefined in python.







                  share|improve this answer























                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    Try this:



                    import re

                    s="<big>t<big>his should be <big>u<big>ppercase"

                    result = re.finditer('<big>(.)<big>', s)

                    for i in result:
                    s = s.replace(i.group(0), i.group(1).upper())


                    Note:




                    Do not use str as a name of a variable. str is predefined in python.







                    share|improve this answer












                    Try this:



                    import re

                    s="<big>t<big>his should be <big>u<big>ppercase"

                    result = re.finditer('<big>(.)<big>', s)

                    for i in result:
                    s = s.replace(i.group(0), i.group(1).upper())


                    Note:




                    Do not use str as a name of a variable. str is predefined in python.








                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered yesterday









                    mehrdad-pedramfar

                    3,32511232




                    3,32511232






















                        up vote
                        0
                        down vote













                        Those don't look like real xml tags. But assuming the number of <big> tags are used correctly, you can split it by tag and apply upper() to strings between.



                        text = "<big>t<big>his should be <big>u<big>ppercase"

                        split_str = text.split('<big>')
                        result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])





                        share|improve this answer








                        New contributor




                        boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.






















                          up vote
                          0
                          down vote













                          Those don't look like real xml tags. But assuming the number of <big> tags are used correctly, you can split it by tag and apply upper() to strings between.



                          text = "<big>t<big>his should be <big>u<big>ppercase"

                          split_str = text.split('<big>')
                          result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])





                          share|improve this answer








                          New contributor




                          boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.




















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Those don't look like real xml tags. But assuming the number of <big> tags are used correctly, you can split it by tag and apply upper() to strings between.



                            text = "<big>t<big>his should be <big>u<big>ppercase"

                            split_str = text.split('<big>')
                            result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])





                            share|improve this answer








                            New contributor




                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            Those don't look like real xml tags. But assuming the number of <big> tags are used correctly, you can split it by tag and apply upper() to strings between.



                            text = "<big>t<big>his should be <big>u<big>ppercase"

                            split_str = text.split('<big>')
                            result = ''.join([x.upper() if i % 2 else x for i, x in enumerate(split_str)])






                            share|improve this answer








                            New contributor




                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered yesterday









                            boonwj

                            1114




                            1114




                            New contributor




                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            boonwj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238506%2fmake-character-in-tag-uppercase-and-remove-tag%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest




















































































                                Popular posts from this blog

                                Xamarin.iOS Cant Deploy on Iphone

                                Glorious Revolution

                                Dulmage-Mendelsohn matrix decomposition in Python