Community
    • Login

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

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 6 Posters 1.4k 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.
    • Alan KilbornA
      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
        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
          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors