Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace all method throws PatternSyntaxException
    primarykey
    data
    text
    <p>look at the following code: </p> <pre><code>String comment = "1)FCR pick up in Hong Kong2)Local charges will be paiy in Hong Kong &amp; in HK$.3)Booking:virginiawong@fahkco.com.hk4)FCR&amp;DOC:emilywu@fahkco.com.hkTel:00852-23021977Fax:00852-2730217Transaction865320submittedVirginiaWong(T1281954U005) and Status is INCMP on 10-JUN-11 11.28.45.764386 PM -05:00"; //comment = comment.replaceAll("\\)", "\\\\)"); //comment = comment.replaceAll("\\(", "\\\\("); if(comment == null || comment.length() &lt; 100) { System.out.println(); } String[] strArray = comment.split(" "); for (int i = 0; i &lt; strArray.length; i++) { if(strArray[i].length() &gt; 100) { int iter = strArray[i].length() / 100 ; int count = 100 ; int initCount = 0 ; String strReplace = null; for(int j =0 ; j&lt; iter ; j++) { strReplace = strArray[i].substring(initCount ,count); String strToReplace = strReplace + "\n" ; comment = comment.replaceAll(strReplace,strToReplace); //comment = comment.replaceAll("\\)", "\\\\)"); //comment = comment.replaceAll("\\(", "\\\\("); //comment = comment.replaceAll("\\\\", ""); System.out.println(comment); System.out.println(comment.contains("\n")); initCount = count; //+1 ; count = count +100 ; } } } } </code></pre> <p><br> When I run I get the following exception:<br></p> <blockquote> <p>Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing ')' <br>near index 4 HK$.3)Booking:virginiawong@fahkco.com.hk4)FCR&amp;DOC:emilywu@fahkco.com.hkTel:00852-<br>23021977Fax:00852-2</p> </blockquote> <p>From my understanding I have to escape the parantheses'(',')', I tried to do this(look at the commented part in the code)there was nt any exception but the newline I am appending to the string doesn't seem to appear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload