Using sets to find A-Za-z plus the # and - chars ..?
-
@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”.
-
@Alan-Kilborn hahahah yes no way would I bet my house on any regular expression I recommend covering all, no matter how perverse, eventualities…
-
Hello, @peterjones,
In my previous post, I forgot to mention the
^
character, which has a special meaning within aCharacter 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