Unified-Hosts-AutoUpdate icon indicating copy to clipboard operation
Unified-Hosts-AutoUpdate copied to clipboard

Literals vs. Regular Expressions

Open ScriptTiger opened this issue 6 years ago • 2 comments

When I first put this script together I wasn't sure what kind of user base I would be dealing with and I decided to go with literal expressions in the ignore file because you can just put the line exactly as it is that you want to ignore and you don't need any special characters and it makes it a bit easier for the less technically inclined. However, from what I have seen I think the users here are more than able to navigate the much more powerful regular expressions, but I'll be sure to include plenty of examples as needed to get those less technically inclined where they need to be to get the outcome that they want. This move will, however, break whatever ignore lists users currently have in place, so I just wanted to post this as an issue before implementing anything to get some feedback, give some warning, etc. The change itself would just be changing a single command, but the implications for the users are much greater. So let me know what you think and hopefully make me feel less guilty about going through with it.

A similar update script which already uses regular expressions is my DualServer updater: https://github.com/ScriptTiger/DualServer I went with regular expressions with DualServer because literals aren't as helpful in the DualServer format and being a DNS server it should be as configurable as possible.

You can google more info on regular expressions (RegEx), but here's a brief cheat sheet:

. Wildcard: any character
* Repeat: zero or more occurrences of previous character or class
^ Line position: beginning of line
$ Line position: end of line
[class] Character class: any one character in set
[^class] Inverse class: any one character not in set
[x-y] Range: any characters within the specified range
\x Escape: literal use of metacharacter x
<xyz Word position: beginning of word
xyz> Word position: end of word

ScriptTiger avatar Mar 26 '18 04:03 ScriptTiger

I suppose a better solution might also be implementing an option for literals or RegEx and leaving the default as literals so nothing is broken during the update. I don't want my personal preference to blind my effectiveness at making this script accessible to as many people as possible.

ScriptTiger avatar Mar 26 '18 04:03 ScriptTiger

I suppose a better solution might also be implementing an option for literals or RegEx and leaving the default as literals so nothing is broken during the update. I don't want my personal preference to blind my effectiveness at making this script accessible to as many people as possible.

Sounds good

ohadschn avatar Jan 03 '20 10:01 ohadschn