Community
    • Login

    reg expressions Multiple search

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 899 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.
    • claudio pergolinC Offline
      claudio pergolin
      last edited by

      hi all, I need to find, using regular expressions in notepad ++, all words preceded by the dollar sign “$” and a space starting with “a” and / or “b” and / 0 “bah” .
      I tried with the following expression but it just finds all combinations of a and b but it doesn’t find “bah”.

      \$((\s)+)((a|b|bah)+)
      

      Any suggestions? thank you

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @claudio pergolin
        last edited by

        @claudio-pergolin

        Put your bah as an earlier alternative?

        Maybe \$((\s)+)((bah|a|b)+)

        1 Reply Last reply Reply Quote 1
        • claudio pergolinC Offline
          claudio pergolin
          last edited by

          yes, weird thing is that if “bah” I put it as the first option that is “\ $ ((\ s) +) ((blah | a | b) +)” is found.
          How is it possible?
          Hello and thanks

          Alan KilbornA PeterJonesP 2 Replies Last reply Reply Quote 0
          • Alan KilbornA Offline
            Alan Kilborn @claudio pergolin
            last edited by

            @claudio-pergolin said in reg expressions Multiple search:

            yes, weird thing is that if “bah” I put it as the first option that is “\ $ ((\ s) +) ((blah | a | b) +)” is found.

            Can’t tell what that means.
            Please provide examples.

            claudio pergolinC 1 Reply Last reply Reply Quote 0
            • PeterJonesP Offline
              PeterJones @claudio pergolin
              last edited by

              @claudio-pergolin said in reg expressions Multiple search:

              How is it possible?

              Because the order of search terms matters in alternations (OR conditions). The problem with searching for b then a then bah is that when it runs across b it says “I match on b”, then it runs across a and says “I match on a” – and it’s already matched the condition of one or more instances of a, b, and bah. It never backtracks to try to find bah because ba was already matching and meeting the requirements of your regex. On the other hand, if bah is listed before the others as bah|a|b, then it tries to match bah before trying either b or a, and then it will match the longer word. The general rule of thumb in alternations is if more than one alternation might match the same text, you need to put the longer or more important alternation first.

              1 Reply Last reply Reply Quote 2
              • claudio pergolinC Offline
                claudio pergolin @Alan Kilborn
                last edited by

                @Alan-Kilborn said in reg expressions Multiple search:

                Non so cosa significhi.
                Fornisci esempi.

                Se nella mia espressione di ricerca faccio occupare a “bah” la prima alternanza, invece dell’ultima posizione ( vedi primo mio post), quindi:

                \$((\ s)+)((bah|a|b)+)
                

                In tal caso mi trova anche la parola che incomincia con “$ bah”

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA Offline
                  Alan Kilborn @claudio pergolin
                  last edited by

                  @claudio-pergolin

                  Posting in your native language isn’t going to help me understand, it’s just going to make me translate it to English – if I feel like it – when that is something you should do before posting on an English language forum.

                  Probably the part that confused me the most was not anything to do with language, it was that you suddenly introduced blah instead of bah into it.

                  Anyway, I think probably Peter’s reply cleared up any confusion for you.
                  Cheers!

                  claudio pergolinC 1 Reply Last reply Reply Quote 0
                  • claudio pergolinC Offline
                    claudio pergolin @Alan Kilborn
                    last edited by claudio pergolin

                    @Alan-Kilborn said in reg expressions Multiple search:

                    @claudio-pergolin

                    Posting in your native language isn’t going to help me understand, it’s just going to make me translate it to English – if I feel like it – when that is something you should do before posting on an English language forum.

                    Probably the part that confused me the most was not anything to do with language, it was that you suddenly introduced blah instead of bah into it.

                    Anyway, I think probably Peter’s reply cleared up any confusion for you.
                    Cheers!

                    sorry but with chrome that translates automatically, I forgot to translate it directly into English …sorry!

                    1 Reply Last reply Reply Quote 1

                    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