Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Replace lowercase with uppercase between brackets

    Help wanted · · · – – – · · ·
    4
    11
    1021
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Hank K
      Hank K last edited by

      Need to change varying text between square brackets to UPPERCASE.

      Change [help wanted] to [HELP WANTED]

      Found an Tried the following regex:

      [([^]\r\n]*)] … Invalid regular expression!
      Invalid regular expresion.jpg (see pic attached)

      (?-s)[.*?] … All this does is finds . and/or ? in the file

      [([^]]*)] … Invalid regular expression

      1 Reply Last reply Reply Quote 1
      • Terry R
        Terry R last edited by Terry R

        @Hank-K said in Replace lowercase with uppercase between brackets:

        Need to change varying text between square brackets to UPPERCASE.

        Your regex was close and it gave me a starting point for one that does work.

        Find What:(?<=[)([^]\r\n]+)
        Replace With:\U\1

        See if that helps you. Now currently it will not edit a string if that string goes over 2 (or more) lines. If you need to allow for multiple lines you could change the find what code to (?<=[)([^]]+).

        Give it a go and please do tell us how you got on, even if not working and let us know what strings it missed. We could alter to suit.

        Terry

        PS forgot to say I also changed the * to a +. In order to change any characters to upper case there must be at least 1 otherwise no sense in selecting it.

        1 Reply Last reply Reply Quote 2
        • Hank K
          Hank K last edited by

          Tried both same, Invalid regular expression!
          Invalid regular expresion R1.jpg

          Does it work for you ? Here’s the exact portion of the text:

          1
          00:00:01,042 --> 00:00:02,919
          [door squeaks open]

          2
          00:00:02,961 --> 00:00:04,337
          [clears throat]

          3
          00:00:04,379 --> 00:00:06,172
          [keys jangle]

          Thanks for the assist Terry … what am I doing wrong ?

          PeterJones 1 Reply Last reply Reply Quote 0
          • Alan Kilborn
            Alan Kilborn last edited by Alan Kilborn

            So, Terry probably meant the regex to be (?<=\[… but this site has some weirdness with posting the backslash-then-left-bracket syntax.

            The fact that the first [ is not escaped is probably the problem here.

            Terry R 1 Reply Last reply Reply Quote 3
            • PeterJones
              PeterJones @Hank K last edited by PeterJones

              @Hank-K said in Replace lowercase with uppercase between brackets:

              Invalid regular expression!

              The forum mangles backslash followed by [ , even in `backticks`, which make just about everything appear literal

              The first should be bd9b459f-1abe-4727-a1e9-edef1d7f4719-image.png

              The second should be 26aef4d2-31ea-4489-b374-b4cba11cc3ce-image.png

              (edit: i unnecessarily escaped the ] in the first one but not the second. talk about consistency; it’ll still find the same things)

              1 Reply Last reply Reply Quote 2
              • Terry R
                Terry R @Alan Kilborn last edited by Terry R

                @Alan-Kilborn said in Replace lowercase with uppercase between brackets:

                The fact that the first [ is not escaped is probably the problem here.

                Yep, right first time. I forgot that bloody interpreter has a way with certain characters, thanks @Alan-Kilborn for providing that fix.

                Terry

                PS apologies @Hank-K , good to see that the seasoned forum members are there to help out. We’ll get you there eventually.

                PPS, so the alternate regex also needs the \ added in the same location.

                1 Reply Last reply Reply Quote 0
                • Hank K
                  Hank K last edited by

                  The accomplishment of an aim or purpose.
                  SUCCESS

                  Thanks so MUCH for the quick replies GUYS … 2 thumbs ~~

                  Hank K 1 Reply Last reply Reply Quote 0
                  • Hank K
                    Hank K last edited by Hank K

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • Hank K
                      Hank K @Hank K last edited by

                      If I wanted to ignore existing UPPERCASE between the brackets ? ? ?
                      Using it in “Find in Files” mode … have a lot existing cases.

                      Trying to MATCH existing files is what started this epic journey … lol

                      1 Reply Last reply Reply Quote 0
                      • Terry R
                        Terry R last edited by

                        @Hank-K said in Replace lowercase with uppercase between brackets:

                        If I wanted to ignore existing UPPERCASE between the brackets ? ? ?

                        That would complicate matters and is probably unnecessary as you want to make all (alpha) characters inside the [] uppercase, who cares if the regex picks one set which is already so, it doesn’t change the outcome, still upper case characters are produced.

                        At the moment the regex picks ALL the characters together, so if some were already upper case do you wish to exclude those and only convert the remainder to upper case. That could be done with a regex, but honestly I think it serves no useful purpose. The conversion to uppercase is what matters, unless we are missing something you wish to convey but haven’t been able to so far?

                        Terry

                        1 Reply Last reply Reply Quote 1
                        • Hank K
                          Hank K last edited by

                          NP …Thanks again Terry … Cheers

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright © 2014 NodeBB Forums | Contributors