// To Source converts string format such as "(12,123123)" to Source Type func ToSource(sourceStr dna.String) Source { if sourceStr.Match(`\([0-9]+,[0-9]+\)`) == false { panic("Wrong Source format") } sourArr := sourceStr.ReplaceWithRegexp(`^\(|\)$`, "").Split(",") return Source{sourArr[0].ToInt(), sourArr[1].ToInt()} }
func getLabelFromDesc(desc dna.String) dna.String { var ret dna.String label := desc.FindAllString(`(?i)label:?.+`, 1) if label.Length() > 0 { ret = label[0].ReplaceWithRegexp(`(?i)label:?`, "").Trim() if ret.FindAllString(`(?mis)(.)?Publisher(\s)+:?.+`, 1).Length() > 0 { ret = ret.ReplaceWithRegexp(`(?mis)(.)?Publisher(\s)+:?`, "").Trim() } return ret } if desc.FindAllString(`℗.+`, 1).Length() > 0 { ret = desc.FindAllString(`℗.+`, 1)[0].ReplaceWithRegexp(`℗`, "").ReplaceWithRegexp(`[0-9]{4}`, "").Trim() return ret } if label.Length() > 0 { ret = label[0].ReplaceWithRegexp(`(?mis)/?PUBLISHER(\s+)?:?`, "").Trim() return ret } label = desc.FindAllString(`(?mis).?Publisher(\s)+:?.+`, 1) if label.Length() > 0 { ret = label[0].ReplaceWithRegexp(`(.+)?Publisher(\s)+:?`, "").Trim() } return ret }