The second method is a little cleaner and allows partial negation of netnames in addition to the $.
===================================
^(~?[a-zA-Z_0-9+-.]+)$
^ is the begininig, $ is the end
() is a capturing group
~? is zero or one ~ at the start of the matching string
[a-zA-Z_0-9+-.] is the list of legal characters
+ is one or more of the characters of the legal character list
=================================================
^([a-zA-Z_0-9+-.~$]*)$
^ is the begininig, the final $ is the end
() is a capturing group
[a-zA-Z_0-9+-.~$] is the list of legal characters
* is zero or more of the characters in the legal character list
=====================================
- What is the significance of removing the "?" -- this allows for the partial negation of netnames -- net~name~fred would have the inversion bar only over name.
- What is the significance of changing the "+" to "*" -- one vs. zero
- Did the position of "~" in the string make a difference? -- see the first answer...