• Login
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.
  • M
    Michael Wenzel
    last edited by Jan 25, 2019, 7:54 PM

    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!

    M 1 Reply Last reply Jan 25, 2019, 7:58 PM Reply Quote 0
    • M
      Meta Chuh moderator @Michael Wenzel
      last edited by Meta Chuh Jan 25, 2019, 8:10 PM Jan 25, 2019, 7:58 PM

      @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
      • M
        Michael Wenzel
        last edited by Jan 25, 2019, 8:20 PM

        @Meta-Chuh

        THX

        M 1 Reply Last reply Jan 25, 2019, 8:36 PM Reply Quote 1
        • M
          Meta Chuh moderator @Michael Wenzel
          last edited by Meta Chuh Jan 25, 2019, 9:33 PM Jan 25, 2019, 8:36 PM

          @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

          A 1 Reply Last reply Jan 25, 2019, 8:41 PM Reply Quote 1
          • A
            Alan Kilborn @Meta Chuh
            last edited by Jan 25, 2019, 8:41 PM

            @Meta-Chuh said:

            (s.h)

            Facepalm! :)

            M 1 Reply Last reply Jan 25, 2019, 8:42 PM Reply Quote 0
            • M
              Meta Chuh moderator @Alan Kilborn
              last edited by Jan 25, 2019, 8:42 PM

              @Alan-Kilborn

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

              A 1 Reply Last reply Jan 25, 2019, 8:48 PM Reply Quote 0
              • A
                Alan Kilborn @Meta Chuh
                last edited by Jan 25, 2019, 8:48 PM

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

                M 1 Reply Last reply Jan 25, 2019, 8:55 PM Reply Quote 0
                • M
                  Meta Chuh moderator @Alan Kilborn
                  last edited by Jan 25, 2019, 8:55 PM

                  @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
                  • E
                    Eko palypse
                    last edited by Jan 25, 2019, 9:00 PM

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

                    A M 2 Replies Last reply Jan 25, 2019, 9:01 PM Reply Quote 0
                    • A
                      Alan Kilborn @Eko palypse
                      last edited by Alan Kilborn Jan 25, 2019, 9:03 PM Jan 25, 2019, 9:01 PM

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

                      M 1 Reply Last reply Jan 25, 2019, 9:05 PM Reply Quote 2
                      • M
                        Meta Chuh moderator @Eko palypse
                        last edited by Jan 25, 2019, 9:01 PM

                        @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
                        • E
                          Eko palypse
                          last edited by Jan 25, 2019, 9:02 PM

                          LOL :-D

                          1 Reply Last reply Reply Quote 0
                          • M
                            Meta Chuh moderator @Alan Kilborn
                            last edited by Jan 25, 2019, 9:05 PM

                            @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
                            • P
                              PeterJones
                              last edited by Jan 25, 2019, 9:32 PM

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

                              E 1 Reply Last reply Jan 25, 2019, 9:49 PM Reply Quote 3
                              • M
                                Meta Chuh moderator
                                last edited by Jan 25, 2019, 9:40 PM

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

                                1 Reply Last reply Reply Quote 3
                                • E
                                  Eko palypse @PeterJones
                                  last edited by Jan 25, 2019, 9:49 PM

                                  @PeterJones said:

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

                                  even easily understandable for me :-D

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