// NOTE: the 4 spaces comes from the implementation of printtab2buff
// in deparse.c -- it is hard-coded to use 4 spaces for the first 4
// levels of indentation and then 2 spaces for subsequent levels.
final String replaceWith = replaceText;
Pattern pattern = Pattern.create("^( ){1,4}");
code = pattern.replaceAll(code, new ReplaceOperation()
{
@Override
public String replace(Match m)
{
return m.getValue().replace(" ", replaceWith);
}
});
Pattern pattern2 = Pattern.create("^\t{4}( )+");
code = pattern2.replaceAll(code, new ReplaceOperation()
{
@Override
public String replace(Match m)
{
return m.getValue().replace(" ", replaceWith);