SOLVED

Query about RegEx

MVP

In creating the config.json file, one probably needs to enter regex stri ngs for process executable matching.  In reading the code, it appears that the code is using C++ std regex libraries for this purpose, rather than standard Json Regex.  

 

I believe the appropriate reference for this RegEx is https://docs.microsoft.com/en-us/cpp/standard-library/regular-expressions-cpp?view=vs-2017#grammarsu... and that the default syntax ECMAScript is being used.  Please confirm this. 

 

I think we need this documented somewhere other than in the code.  Yes, this might not be the place for documentatin, but somewhere.

 

2 Replies
best response confirmed by John Vintzel (Microsoft)
Solution

Hi Tim,

 

Yes, this is the scheme and the default syntax (ECMA) we use.

Thanks for bringing it up, we will add it to our docs.

 

Thanks!

Vlad

Thanks - I initially assumed it was the syntax normally associated with json.  While not substantially different, it does affect options on how to write the syntax for the RegEx string.

 

For anyone having an issue with using the RegEx in the config.json, the following information might be helpful.

 

The "executable" ParameterName under "processes" should be written as a RegEx string using the standard Microsoft implementation with ECMAScript syntax.  This RegEx string is being compared to the process name, but without the ".exe" on the tail. Additionally, although the examples imply that the full path for the processes application is used, it is not.  If one wishes to use the most exacting match (to prevent accidental matches to other exe files in the package), then you might consider using a string without wildcards and anchoring at the end of the string.

 

For example, consider a package with the following exe filenames:

    Name.exe

    Name_andMore.exe

   The_Name_InTheMiddle.exe

    FrontEndedName.exe

 

If you want to match only Name.exe, you could use the RegEx string

   Name$

and it will only match the first case. 

 

Keep in mind that consideration might be necessary for case changes.  For example, the app might register the first name inside the registry as NAME.exe and when used by an app in the package to launch it, is not clear if PSRuntime would be matching on the filename (Name) or requested filename (NAME).  I think it uses the filename, but without an example to test I'm not sure.

 

Also keep in mind the special RegEx characters that need to be escaped.  For example "Notepad++" would use a RegEx string like "Notepad\+\+$".  See RegEx documentation for a full list of those special characters.

 

1 best response

Accepted Solutions
best response confirmed by John Vintzel (Microsoft)
Solution

Hi Tim,

 

Yes, this is the scheme and the default syntax (ECMA) we use.

Thanks for bringing it up, we will add it to our docs.

 

Thanks!

Vlad

View solution in original post