申し訳ありませんが、これは自分のライブラリから生成したもので、Dart / Javascript / Java / Pythonに有効な構文を使用していますが、とにかく、次のようになります。
(?:^)(?:(?:[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKlMNOPQRSTUVWXYZ0123456789]){1,1})(?!(?:(?:(?:(?:_\.){1,1}))|(?:(?:(?:__){1,1}))|(?:(?:(?:\.\.){1,1}))))(?:(?:(?:(?:[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKlMNOPQRSTUVWXYZ0123456789._]){1,1})(?!(?:(?:(?:(?:_\.){1,1}))|(?:(?:(?:__){1,1}))|(?:(?:(?:\.\.){1,1}))))){6,18})(?:(?:[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKlMNOPQRSTUVWXYZ0123456789]){1,1})(?:$)
私のライブラリコード:
var alphaNumeric = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "l", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var allValidCharacters = new List.from(alphaNumeric);
allValidCharacters.addAll([".", "_"]);
var invalidSequence = (r) => r
.eitherString("_.")
.orString("__")
.orString("..");
var regex = new RegExpBuilder()
.start()
.exactly(1).from(alphaNumeric).notBehind(invalidSequence)
.min(6).max(18).like((r) => r.exactly(1).from(allValidCharacters).notBehind(invalidSequence))
.exactly(1).from(alphaNumeric)
.end()
.getRegExp();
私のライブラリ:https ://github.com/thebinarysearchtree/RegExpBuilder