/* * [JavaRegexCSV.java] * * Summary: Java Regex Search strings reserve chars for regex use. * * Copyright: (c) 2002-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 4.5 2009-02-26 add both Java string quoting and plain for Java search/regexes. */ package com.mindprod.quoter; import com.mindprod.fastcat.FastCat; /** * Java Regex Search strings reserve chars for regex use. *

* These must be quoted with a leading \. - + * ? ( ) [ ] \ | $ ^ * < = * * @author Roedy Green, Canadian Mind Products * @version 4.5 2009-02-26 add both Java string quoting and plain for Java search/regexes. * @since 2002-06-19 */ class JavaRegexCSV extends Translator { /** * add Java search regex quoting, then Java string literal quoting. * * @param raw text to be translated. * * @return String representing the cooked output, possibly null. */ public String process( String raw ) { assert raw != null : "TextProcessor.process raw must not be null"; final Translator toCSV = new ToCSV(); final FastCat sb = new FastCat( 6 ); sb.append( "outside [ ]:\n", toCSV.process( JavaRegex.cookOutsideRegex( raw ) ) ); sb.append( "\n\ninside [ ]:\n", toCSV.process( JavaRegex.cookInsideRegex( raw ) ) ); sb.append( "\n\nas replacement:\n", toCSV.process( JavaRegex.cookReplacementRegex( raw ) ) ); return sb.toString(); } // end process }