stringToSymbol function

Symbol stringToSymbol(
  1. String s
)

Convert string to Symbol. format: precision,NAME. */

Implementation

Symbol stringToSymbol(String s) {
  RegExp exp = RegExp(r"^([0-9]+),([A-Z]+)$");
  var m = exp.allMatches(s).toList();
  if (!exp.hasMatch(s)) {
    throw 'Invalid symbol';
  }
  return Symbol(name: m[2].toString(), precision: int.parse([1].toString()));
}