Author |
Topic |
|
3di
Germany
26 Posts |
Posted - 03/03/2017 : 04:07:12
|
Hi,
I experienced a strange behavior I would like to ask you about.
I created a folder for several Apps (i am using Text Shortcuts for them). I would like to choose several apps for those, I did this using a “file name pattern” for.
Word.exe|outlook.exe|firefox.exe|chrome.exe|iexplore.exe|notepad.exe|notepad++.exe
All Apps, except Notepad++.exe are working well. I tried notepad**.exe instead – but S+ instantly keeps crashing when I use one of the strokes in this folder.
Another Question is, is it possible to create sub Folders, or is it possible to generate a Folder that is used in general for all apps like the Global Actions Folder - just to create some structure (I use a lot of strokes in common)?
|
|
Rob
USA
2615 Posts |
Posted - 03/03/2017 : 08:40:09
|
Unfortunately, no support for subfolders exist at this time.
Regarding your pattern, the matching uses regular expression. Check out this site for in-depth details on usage and make use of the Regex Tester to validate your patterns: http://regexlib.com.
Regex has specific syntax and to be honest, S+ does not attempt to validate the syntax, which is why your use of invalid syntax causes a crash. Periods and asterisks have special meaning and cannot be directly used as you have in your pattern, well not without understanding what they do.
For example, a period means "any character here". So, a pattern of "Word.exe" technically works fine because a period is, in fact, "any character" so it works coincidentally with your expectations.
However, an asterisk means any amount of repetitions of the preceding identifier. So with "notepad**.exe", the first asterisk is instructing the engine to allow any number of "d" characters after "notepa". For example, "notepad" or "notepadddddddd" would constitute a match. The crash comes with the second asterisk, as the preceding character is also an asterisk, specifically an unescaped asterisk which isn't a valid pattern.
To escape reserved/special characters, you precede them with a backslash, so for Word.exe, you really want "Word\.exe". Escaping a character tells the regex engine to treat the character literally and not as a special symbol, so "\." means "only match for a period", instead of the reserved function of "match any character". Again, your pattern conveniently works, but it would also match on "Wordfexe" or "Word9exe", while the pattern "Word\.exe" will only match on "Word.exe".
Following these rules laid out above, it will probably make sense why the pattern below is more what you're looking for.
Word\.exe|outlook\.exe|firefox\.exe|chrome\.exe|iexplore\.exe|notepad\.exe|notepad\+\+\.exe |
|
|
Rob
USA
2615 Posts |
Posted - 03/03/2017 : 08:43:59
|
Also note that the + symbol means 1 or more of the preceding identifier, which is why they must also be escaped, the * technically is 0 or more of the preceding identifier. |
|
|
Rob
USA
2615 Posts |
Posted - 03/03/2017 : 08:56:37
|
For more fun, you can make it even shorter by creating groups instead of repeating the exe part of the match, and demonstrate the usage of period and asterisk working together.
(Word|outlook|firefox|chrome|iexplore|notepad.*)\.exe
The items inside parenthesis process as a group and since they're separated by pipes (logical ORs), only one will match then it will attempt to match the remaining expression of ending in ".exe". You'll notice I used "notepad.*" to match both on notepad and notepad++. Remember, that ".*" means "any character" and any amount of "any character" since the preceding identifier is a period.
Although, this would technically also match on "notepadblahblah.exe", so it's not really a perfect pattern if you have other programs beginning with "notepad". But I just wanted to demonstrate the functionality. |
|
|
3di
Germany
26 Posts |
Posted - 03/03/2017 : 09:12:17
|
thanks Rob,
your (Word|outlook|firefox|chrome|iexplore|notepad.*)\.exe works like a charm - thanks a lot.
Also for your little "things to know" excursion about Astrerix and so on :-).
I must admit that I have never thought about it :-).
Best Regards, and have a great weekend.
3di |
|
|
Hard.Wired
84 Posts |
Posted - 03/06/2017 : 17:26:12
|
Niiice! |
|
|
|
Topic |
|
|
|