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

12
LINES

< > BotCompany Repo | #2000458 // Short syntax for dynamic replace in Java(X)

New Tinybrain snippet

Full:

    Matcher m = Pattern.compile("(#\\d+)").matcher(text);
    new StringBuffer buf;    // cool "quicknew" syntax!
    while (m.find())
      m.appendReplacement(buf, m.quoteReplacement(formatSnippetRef(m.group())));
    m.appendTail(buf);
    text = buf.toString();

Short:

    text = text.replaceAll("(#\\d+)", m -> formatSnippetRef(m.group()));

download  show line numbers   

Snippet is not live.

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
78 stefan Now we just need a translator... 2015-07-25 14:00:03

add comment

Snippet ID: #2000458
Snippet name: Short syntax for dynamic replace in Java(X)
Eternal ID of this version: #2000458/1
Text MD5: f14c46b93879e5a2f24141b8bd01905d
Author: stefan
Category:
Type: New Tinybrain snippet
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-07-25 13:46:04
Source code size: 365 bytes / 12 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 920 / 181
Referenced in: [show references]