import Foundation extension String { //絵文字など(2文字分)も含めた文字数を返します var length: Int { let string_NS = self as NSString return string_NS.length } //正規表現の検索をします func pregMatche(pattern: String, options: NSRegularExpression.Options = []) -> Bool { guard let regex = try? NSRegularExpression(pattern: pattern, options: options) else { return false } let matches = regex.matches(in: self, options: [], range: N