|
Friki example source code file (b.txt)
The Friki b.txt source code
package org.stringtree.regex;
class ResultGeneratorSubstitution
implements jregex.Substitution
{
private ResultGenerator gen;
public ResultGeneratorSubstitution(ResultGenerator gen)
{
this.gen = gen;
}
public void appendSubstitution(jregex.MatchResult match, jregex.TextBuffer tb)
{
tb.append(gen.result(new Matcher((jregex.Matcher)match)));
}
}
public class Pattern
{
public static String processor="jregex";
protected jregex.Pattern pattern;
public Pattern(jregex.Pattern pattern)
{
this.pattern = pattern;
}
public static Pattern compile(String text)
{
return new Pattern(new jregex.Pattern(text, jregex.REFlags.MULTILINE));
}
public Matcher matcher(String text)
{
return new Matcher(pattern.matcher(text));
}
public String replaceAll(String input, ResultGenerator generator)
{
jregex.Replacer replacer = new jregex.Replacer(pattern,
new ResultGeneratorSubstitution(generator));
return replacer.replace(input);
}
public String replaceAll(String input, String value)
{
jregex.Replacer replacer = pattern.replacer(value);
return replacer.replace(input);
}
public String[] split(String input)
{
jregex.RETokenizer tok = pattern.tokenizer(input);
tok.setEmptyEnabled(true);
return tok.split();
}
}
Other Friki examples (source code examples)Here is a short list of links related to this Friki b.txt source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.