Author Topic: Powershell identifier characters  (Read 255 times)


  • Senior Community Member
  • Posts: 2278
  • Hero Points: 196
  • Text
Powershell identifier characters
« on: May 08, 2021, 01:01:49 am »
I think that the definition for powershell identifier characters is wrong.
First, a question: What format is "ID start characters" and "ID follow characters"?
Does slick take these fields and surround with '[' and ']', then call it a Slick regex?

The default definition is missing underscore, and lots of weird unicode digits [\p{Nd}]
The rules for identifiers is a bit complex, and maybe Slickedit cannot really capture it?
The rules for identifiers in general is slightly different that the rules for variable names.

"Normal" variables should always start with $, followed by
  • \p{L} (Lu, Ll, Lt, Lm, Lo)
  • \p{Nd} (not just 0-9)
  • _
  • ?

Typically dash is not allowed in $variable $names - but you can also have dashes, spaces or just about any character using this syntax:
Code: [Select]
${My Crazy Variable with-dashes-too} = "value"
Identifiers, such as function names, don't start with $.
They can have dash.
There is also the back-tick escape to allow just about any character in an identifier.

I'd be happy for slick to ignore the CrazyVariable case though.

(Why? Why make it so complex? Do we really need to allow variable names with spaces? With control characters?)


  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5943
  • Hero Points: 467
Re: Powershell identifier characters
« Reply #1 on: May 10, 2021, 03:08:32 am »
I had to write some code to test all unicode characters. Almost all are supported. Way more than [\p{L}\p{Nd}_\-?]