-
Notifications
You must be signed in to change notification settings - Fork 49
Account for curly quotes in syntax definition. #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @PSPally, there's something funky about your quotation marks. They look like
Did you copy that code from a document editor like Microsoft Word or Wordpad? You may wish to look at an extension like https://marketplace.visualstudio.com/items?itemName=jinhyuk.replace-curly-quotes if this is a common occurrence. Param (
# User account to be modified, this can be any value that Get-ADUser will accept
[Parameter(Mandatory = $true)]
$User,
[Parameter(Mandatory = $true)]
[Int32]$TicketNumber,
# New last name of the person
[ValidatePattern("^[-'a-z]$")]
[Parameter(Mandatory = $true)]
$NewLastName,
# User's middle name
[ValidatePattern("^[-'a-z]$")]
$NewMiddleName,
# User's new first name,
[ValidatePattern("^[-'a-z]*$")]
$NewFirstName,
# Defines how many characters from the first name will be used. Default is 1.
[Int32]$AlternateAliasFirstNameLength = 1,
# For manually specifing the Display Name
[string]$DisplayName,
[Parameter(DontShow)]
[ValidateSet($True, $False)]
[switch]$Approved = $false
) |
Why notepad will never die... The text version of the code was copied from the PowerShell ISE. |
That's crazy! Powershell accepts those characters as double quotes! PowerShell doesn't even care if they are used in the proper order. EditorSyntax does not accept them at all. |
@PSPally it's not so much that the @tylerl0706 should we account for curly quotes, emdashes, etc in the EditorSyntax? |
@DarkLite1, you're correct. Reopening your original issue. |
So, PowerShell not only supports curly quotes but it doesn't care which ones you use. That is, you can do this: Regex like this: This also needs to be accounted for in escaping. Take this: It's going to take a bit to make sure I get this right. |
@omniomi , regarding the Instead, where I think this regex is used in an END clause, it might be better to use And back references in a END refer to captures in BEGIN. I couldn't get a subroutine call in an END to work, but it worked fine in a MATCH (but |
@omniomi , may want to use |
indirectly applies PowerShell#167 parts 2 and 3
Confirmed using different themes.
Environment
Issue Description
When I use a regular expression that contains a ' then the display will treat it as the beginning, or end, of a test string. The color coding in all themes tests shows all the code as a text string until it encounters another '.
Screenshots
Expected Behavior
Code Samples
Param (
# User account to be modified, this can be any value that Get-ADUser will accept
[Parameter(Mandatory=$true)]
$User,
[Parameter(Mandatory=$true)]
[Int32]$TicketNumber,
# New last name of the person
[ValidatePattern(“^[-'a-z]$”)]
[Parameter(Mandatory=$true)]
$NewLastName,
# User's middle name
[ValidatePattern(“^[-'a-z]$”)]
$NewMiddleName,
# User's new first name,
[ValidatePattern(“^[-'a-z]*$”)]
$NewFirstName,
# Defines how many characters from the first name will be used. Default is 1.
[Int32]$AlternateAliasFirstNameLength = 1,
# For manually specifing the Display Name
[string]$DisplayName,
[Parameter(DontShow)]
[ValidateSet($True,$False)]
[switch]$Approved = $false
)
The text was updated successfully, but these errors were encountered: