Libraryless. Click here for Pure Java version (2244L/14K).
1 | sS regexpQuote_useBackslashes(S s) { |
2 | if (s == null) null; |
3 | StringBuilder buf = null; |
4 | int n = l(s); |
5 | for i to n: { |
6 | char c = s.charAt(i); |
7 | if (regexpSpecialCharacters().indexOf(c) < 0) { |
8 | if (buf != null) buf.append(c); |
9 | } else { |
10 | if (buf == null) buf = new StringBuilder(takeFirst(i, s)); |
11 | buf.append('\\'); |
12 | buf.append(c); |
13 | } |
14 | } |
15 | ret buf == null ? s : buf.toString(); |
16 | } |
Began life as a copy of #1027465
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027480 |
Snippet name: | regexpQuote_useBackslashes |
Eternal ID of this version: | #1027480/4 |
Text MD5: | 60230da54e872234c05aee1097d555f1 |
Transpilation MD5: | c06565a63d4e6e5e4f34f1805d016d23 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-22 14:30:58 |
Source code size: | 425 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 181 / 268 |
Version history: | 3 change(s) |
Referenced in: | [show references] |