persistable srecord RegExp(S pattern, bool caseInsensitive) { transient Pattern compiled; S error; *(S *pattern) {} // TODO: don't compile again when error detected? java.util.regex.Pattern compile aka get() { try { compiled if null = compileRegexpPossiblyIC(pattern, caseInsensitive); error = null; ret compiled; } catch e { error = exceptionToStringShort(e); null; } } bool valid() { ret compile() != null; } bool containsSpecialChars() { ret containsRegExpSpecialChars(pattern); } bool containedIn(S s) { ret regexpContains(getForce(), s); } java.util.regex.Pattern getForce() { var pattern = get(); if (error != null) fail(error, pattern); ret pattern; } }