package org.supercsv.cellprocessor;

import java.util.regex.Pattern;

import org.supercsv.cellprocessor.ift.BoolCellProcessor;
import org.supercsv.cellprocessor.ift.StringCellProcessor;
import org.supercsv.exception.NullInputException;
import org.supercsv.util.CSVContext;

/**
 * Replaces each substring of the input string that matches the given regular expression with the given replacement.
 * 
 * @author Dominique De Vito
 * @since 1.50
 */
public class StrRegExReplace extends CellProcessorAdaptor implements StringCellProcessor {

private final Pattern regexPattern;
private final String replacement;

public StrRegExReplace(final String regex, final String replacement, final BoolCellProcessor next) {
	super(next);
	if( regex == null ) { throw new NullInputException("Regex cannot be null", this); }
	this.regexPattern = Pattern.compile(regex);
	this.replacement = replacement;
}

/**
 * {@inheritDoc}
 */
@Override
public Object execute(final Object value, final CSVContext context) {
	if( value == null ) { throw new NullInputException("Input cannot be null on line " + context.lineNumber
		+ " at column " + context.columnNumber, context, this); }
	String result = regexPattern.matcher((String) value).replaceAll(replacement);
	return next.execute(result, context);
}
}

@@ -623,16 +623,270 @@
 ent;%0D%0A%0D%0A
+public StrRegExReplace(final String regex, final String replacement) %7B%0D%0A%09super();%0D%0A%09if( regex == null ) %7B throw new NullInputException(%22Regex cannot be null%22, this); %7D%0D%0A%09this.regexPattern = Pattern.compile(regex);%0D%0A%09this.replacement = replacement;%0D%0A%7D%0D%0A%0D%0A
 public S

add of new constructors in case of no next processor