title: Powershell's -match and punctuation
body: <p>I'm trying to write a function in Powershell that tests if a string ends with punctuation. Right now that method looks like this:</p>
  
  <pre><code>function ends_in_punctuation #Tests whether or not a word ends in punctuation
  {
      param([string]$WordToTest) #Takes string to check ending of
      $CharToCheck = $WordToTest[$WordToTest.Length - 1] #Getting last character of string
      $Punctuation = ".?!" #Ending punctuation in english
      If($Punctuation -match $CharToCheck) #If last character is punctuation
      {
          $true #return true
      }
      Else
      {
          $false #return false
      }
  }
  </code></pre>
  
  <p>It works great if the word ends with a period or exclamation point but when the word ends with a question mark it throws this error</p>
  
  <pre><code>[ERROR] parsing "?" - Quantifier {x,y} following nothing.
  [ERROR] At D:\...\PigLatin.ps1:24 char:5
  [ERROR] +     If($Punctuation -match $CharToCheck) #If last character is punctu ...
  [ERROR] +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  [ERROR]     + CategoryInfo          : OperationStopped: (:) [], ArgumentException
  [ERROR]     + FullyQualifiedErrorId : System.ArgumentException
  [ERROR]  
  </code></pre>
  
  <p>And have no idea why. I'm new to PowerShell so any help I can get would be greatly appreciated, thanks!</p>