Libraryless. Click here for Pure Java version (5017L/28K).
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; } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032802 |
Snippet name: | RegExp - encapsulate a regular expression (unparsed and parsed, optionally CI) |
Eternal ID of this version: | #1032802/14 |
Text MD5: | 823482a7bccdd8145b98140fd69cf41a |
Transpilation MD5: | 0ef2c1b3e4d161f3ec8c62ed5bb16e25 |
Author: | stefan |
Category: | javax / regexp |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-11-14 20:57:10 |
Source code size: | 805 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 240 / 414 |
Version history: | 13 change(s) |
Referenced in: | [show references] |