Community
    • Login

    Using sets to find A-Za-z plus the # and - chars ..?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 6 Posters 3.4k 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.
    • Alan KilbornA Offline
      Alan Kilborn @Andrew McP
      last edited by Alan Kilborn

      @Andrew-McP said in Using sets to find A-Za-z plus the # and - chars ..?:

      I really admire you guys for figuring out Regular Expressions

      So if someone says they have “figured out regular expressions”, I pity them. Because it just means they are ripe for an upcoming whipping when a regex misunderstanding of theirs really embarrasses them. :-)

      It pays to always be humble when discussing regular expressions with others. :-)

      I bet you never get lost

      GPS!

      I like the trick of having - as last character before ]

      Not so much a trick, as a logical place to put it when you realize that anywhere except the first or last position it must form some sort of “range”.

      Andrew McPA 1 Reply Last reply Reply Quote 1
      • Andrew McPA Offline
        Andrew McP @Alan Kilborn
        last edited by

        @Alan-Kilborn hahahah yes no way would I bet my house on any regular expression I recommend covering all, no matter how perverse, eventualities…

        1 Reply Last reply Reply Quote 1
        • guy038G Offline
          guy038
          last edited by

          Hello, @peterjones,

          In my previous post, I forgot to mention the ^ character, which has a special meaning within a Character class !

          So, here is an updated version of my previous post :

          If we consider the following CHARACTER CLASS structure :
          
          [.......]
          123456789
          
          The POSSIBLE location(s), in order to find the LITERAL character below, are :
          
          LITERAL Character [    :     POSSIBLE at any position, BETWEEN 2 to 8 
                                       POSSIBLE at any position, BETWEEN 2 to 8, if PRECEDED with an ANTI-SLASH character
          							 
          LITERAL Character ]    :     POSSIBLE at position 2 ONLY
                                       POSSIBLE at any position, BETWEEN 2 to 8, if PRECEDED with an ANTI-SLASH character
          							 
          LITERAL Character -    :     POSSIBLE at position 2
                                       POSSIBLE at position 8
                                       POSSIBLE at any position, BETWEEN 2 to 8, if PRECEDED with an ANTI-SLASH character
          
          LITERAL character ^    :     POSSIBLE at any position, BETWEEN 3 and 8
                                       POSSIBLE at any position, BETWEEN 2 to 8, if PRECEDED with an ANTI-SLASH character
          
          							 
          LITERAL Character \    :     POSSIBLE at any position, BETWEEN 2 to 8, if PRECEDED with an ANTI-SLASH character
          

          And I suppose that @alan-kilborn could add :

          To use a “literal ^” in a character class: Use it directly like any other character, e.g. [ab^c], but right after the opening [ of the class notation ; “escaping” is not necessary (but is permissible), e.g. [ab\^c]

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 2

          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