/// <summary>
 /// Creates an instance, validating the name against a matcher.
 /// <para>
 /// In most cases, a <seealso cref="CharMatcher"/> will be faster than a regex <seealso cref="Pattern"/>,
 /// typically by over an order of magnitude.
 ///
 /// </para>
 /// </summary>
 /// <param name="name">  the name, not empty </param>
 /// <param name="matcher">  the matcher for validating the name </param>
 /// <param name="msg">  the message to use to explain validation failure </param>
 protected internal TypedString(string name, CharMatcher matcher, string msg)
 {
     ArgChecker.notEmpty(name, "name");
     ArgChecker.notNull(matcher, "pattern");
     ArgChecker.notEmpty(msg, "msg");
     if (matcher.matchesAllOf(name) == false)
     {
         throw new System.ArgumentException(msg);
     }
     this.name = name;
 }
 /// <summary>
 /// Tries to parse a currency from the input string.
 /// <para>
 /// Parsing is case insensitive.
 ///
 /// </para>
 /// </summary>
 /// <param name="str">  the string to parse, may be null </param>
 /// <returns> the parsed currency, empty if unable to parse </returns>
 public static Optional <Currency> tryParseCurrency(string str)
 {
     if (!string.ReferenceEquals(str, null) && str.Length == 3 && CURRENCY_MATCHER.matchesAllOf(str))
     {
         try
         {
             return(Currency.parse(str));
         }
         catch (Exception)
         {
             // ignore
         }
     }
     return(null);
 }