Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1032802 - RegExp - encapsulate a regular expression (unparsed and parsed, optionally CI)

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (4083L) is out of date.

persistable srecord RegExp(S pattern, bool caseInsensitive) {
  transient Pattern compiled;
  S error;
  
  *(S *pattern) {}

  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);
  }
}

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/11
Text MD5: 01ad00f2ee780a3ad8a70a3dffdbc8a4
Author: stefan
Category: javax / regexp
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-13 16:22:01
Source code size: 537 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 28 / 93
Version history: 10 change(s)
Referenced in: [show references]