Community
    • Login

    RegEx: Modify text between sh. and ( to lowercase

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    16 Posts 5 Posters 2.3k Views
    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.
    • Michael WenzelM
      Michael Wenzel
      last edited by

      Hi,
      I need help again in term of using regular expression for filtering.

      I have a lot of text to modify.
      The part of the text I have to modify to lower case after sh. and before (.

      Here are two examples:
      sh.Wetter.Darksky.currently.windSpeed.beaufort_string(“Windstille”)
      sh.Tankstellen.Metro_Eibach.diesel(element[‘diesel’])

      to be be converted to
      sh.wetter.darksky.currently.windSpeed.beaufort_string(“Windstille”)
      sh.tankstellen.metro_eibach.diesel(element[‘diesel’])

      Thank you!

      Meta ChuhM 1 Reply Last reply Reply Quote 0
      • Meta ChuhM
        Meta Chuh moderator @Michael Wenzel
        last edited by Meta Chuh

        @Michael-Wenzel

        you can easily do this by using a regex search/replace in notepad++

        find what: (sh.)(.*?)(\()
        replace with: $1\L$2$3
        search mode: regular expression

        gives you:

        sh.wetter.darksky.currently.windspeed.beaufort_string("Windstille")
        sh.tankstellen.metro_eibach.diesel(element['diesel'])
        

        as result

        1 Reply Last reply Reply Quote 1
        • Michael WenzelM
          Michael Wenzel
          last edited by

          @Meta-Chuh

          THX

          Meta ChuhM 1 Reply Last reply Reply Quote 1
          • Meta ChuhM
            Meta Chuh moderator @Michael Wenzel
            last edited by Meta Chuh

            @Michael-Wenzel

            you’re welcome.

            here’s a little explanation to get you started using regex so that you can easily adapt them for your needs:

            search what:

            (s.h):
            the first is the beginning text that you are searching for
            the brackets ( and ) define a string buffer, which will be available at the replace as variable $1.
            every time you enclose another section in brackets, you will create a new string buffer variable $2 and so on.

            (.*?):
            this states that the text in between your beginning and the end can be anything with any length.
            it’s content will be reflected as $2

            (\():
            this marks your end search character ( where you want to stop converting to lower case.
            note: this looks weird, but it’s basically a ( bracket in between two brackets.
            to make sure it is interpreted as text and not as a bracket that opens another buffer, it has to be “escaped” marked with a preceeding \.
            it’s easier to read if some spaces are inserted: ( \( )

            replace with:

            $1\L$2$3

            this needs almost no further information.
            the string buffer variables $1 $2 and $2 are put together without spaces, and \L before $2 converts the second string variable to lower case

            Alan KilbornA 1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @Meta Chuh
              last edited by

              @Meta-Chuh said:

              (s.h)

              Facepalm! :)

              Meta ChuhM 1 Reply Last reply Reply Quote 0
              • Meta ChuhM
                Meta Chuh moderator @Alan Kilborn
                last edited by

                @Alan-Kilborn

                i’d call it a typo …
                you’re not in a good mood today, am i right ?

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Meta Chuh
                  last edited by

                  @Meta-Chuh

                  Nono…mood is fine. You seem like a humorous guy, with all the emojis, thought you’d like the “facepalm” thing. Sorry. Certainly didn’t intend to offend.

                  Meta ChuhM 1 Reply Last reply Reply Quote 0
                  • Meta ChuhM
                    Meta Chuh moderator @Alan Kilborn
                    last edited by

                    @Alan-Kilborn
                    ahhh …
                    i only know text based face palm as:

                    (-‸ლ)

                    😂

                    glad you’re in a good mood, i was worried a bit, and i tend to ask freely.

                    1 Reply Last reply Reply Quote 0
                    • Eko palypseE
                      Eko palypse
                      last edited by

                      OOKKKAAAYY - everybody seems to know what facepalms means except … MEEEE. :-)
                      What does it mean??

                      Alan KilbornA Meta ChuhM 2 Replies Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Eko palypse
                        last edited by Alan Kilborn

                        @Eko-palypse

                        I think a possible explanation for facepalm is “I can’t believe I did that”. In the usage above, making a mistake in the regex you are trying to explain the meaning of yields that reaction.

                        Meta ChuhM 1 Reply Last reply Reply Quote 2
                        • Meta ChuhM
                          Meta Chuh moderator @Eko palypse
                          last edited by

                          @Eko-palypse

                          if you hear or see something so stupid, that you have to hit your face with your open hand, it’s called a face palm

                          (-‸ლ)

                          1 Reply Last reply Reply Quote 2
                          • Eko palypseE
                            Eko palypse
                            last edited by

                            LOL :-D

                            1 Reply Last reply Reply Quote 0
                            • Meta ChuhM
                              Meta Chuh moderator @Alan Kilborn
                              last edited by

                              @Alan-Kilborn

                              and i still call it a typo !!! ;-)

                              btw: we’ve just hijacked another thread … but it’s fun from time to time 👍

                              1 Reply Last reply Reply Quote 2
                              • PeterJonesP
                                PeterJones
                                last edited by

                                🤦 U+1F926 (https://emojipedia.org/face-palm/)

                                Eko palypseE 1 Reply Last reply Reply Quote 3
                                • Meta ChuhM
                                  Meta Chuh moderator
                                  last edited by

                                  i guess from now on (s.h) is gonna pursue me as hidden insider to a facepalm (-‸ლ)
                                  😂😂😂

                                  1 Reply Last reply Reply Quote 3
                                  • Eko palypseE
                                    Eko palypse @PeterJones
                                    last edited by

                                    @PeterJones said:

                                    🤦 U+1F926 (https://emojipedia.org/face-palm/)

                                    even easily understandable for me :-D

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors