Character class subtraction

Character class subtraction is supported by .NET (and hence PowerShell). Character class subtraction is not commonly used at all.

Inside a character class, one character class may be subtracted from another, reducing the size of the overall set. One of the best examples of this extends to the character class containing vowels. The following matches the first vowel in a string:

'The lazy cat sat on the mat' -match '[aeiou]' 

To match the first consonant, one approach can be to list all of the consonants:

'The lazy cat sat on the mat' -match '[b-df-hj-np-tv-z]' 

Another approach to the problem is to take a larger character class, then subtract the vowels:

'The lazy cat sat on the mat' -match '[a-z-[aeiou]]' 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.45