Community
    • Login

    expression for specific words

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 793 Views 2 Watching
    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.
    • kracovwolfK Offline
      kracovwolf
      last edited by kracovwolf

      So I got this expression

      ^.*\(.*?\).*\R
      It's for removing all lines containing parenthesis.  But how do I alter it to only target lines that say (music playing) and (ominous music playing)?
      
      mkupperM 1 Reply Last reply Reply Quote 0
      • mkupperM Offline
        mkupper @kracovwolf
        last edited by

        @kracovwolf said in expression for specific words:

        s expression ^.(.?).*\R

        I think something got lost when posting what you tried to the forums.

        The expression was probably ^.*\(.?\).*\R which will remove lines that contain either () or (.) where the dot is any character.

        It’s for removing all lines containing parenthesis. But how do I alter it to only target lines that say (music playing) and (ominous music playing)?

        Try this: ^.*\((music playing|ominous music playing)\).*\R

        You can make it a little more compact using ^.*\((ominous )?music playing\).*\R

        A \( or \) says to match a parentheses in the text,

        kracovwolfK 1 Reply Last reply Reply Quote 1
        • kracovwolfK Offline
          kracovwolf @mkupper
          last edited by

          @mkupper
          isn’t there a better wildcard to also target other ones like suspenseful music playing, etc?

          1 Reply Last reply Reply Quote 0
          • kracovwolfK Offline
            kracovwolf
            last edited by kracovwolf

            how do I also include eerie music, heroic music, etc?

            Mark OlsonM 1 Reply Last reply Reply Quote 0
            • Mark OlsonM Offline
              Mark Olson @kracovwolf
              last edited by Mark Olson

              @kracovwolf said in expression for specific words:

              how do I also include eerie music, heroic music, etc?

              It sounds like you want to match lines that contain the word music. Assuming this is correct, the regular expression (?i-s).*?music.* will match any line that contains that word.

              EXPLANATION:

              • The (?i-s) flag at the beginning makes . not match newline, and turns ignorecase on (I’m assuming you would like to match Music and MUSIC as well as music)
              • .*?music consumes all characters in a line until the word music
              • .* consumes the rest of the characters in the line

              REFERENCES: https://npp-user-manual.org/docs/searching/#regular-expressions

              kracovwolfK 1 Reply Last reply Reply Quote 1
              • kracovwolfK Offline
                kracovwolf @Mark Olson
                last edited by kracovwolf

                @Mark-Olson no, this is in subtitle files. so it has to be strictly “music playing” or “(# music playing)”. How do I do that instead, I don’t know about spacing between the words. this?
                (?i-s).*?music playing.*

                Mark OlsonM 1 Reply Last reply Reply Quote 0
                • Mark OlsonM Offline
                  Mark Olson @kracovwolf
                  last edited by

                  @kracovwolf
                  \s+ matches any number of whitespace characters.

                  I’m not going to give you any more hints on basic regex usage - I will once again recommend that you read the user manual’s topic on regular expressions.

                  While learning regular expressions may be slow going (it took me a long time to get where I am now), believe me when I say that (1) it is worth the effort, and (2) you can’t get there by asking others for the answer.

                  kracovwolfK 1 Reply Last reply Reply Quote 2
                  • kracovwolfK Offline
                    kracovwolf @Mark Olson
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors