I have a StringBuilder and i want to get characters except numbers and following characters(+, -, *, /).
I wrote this code.
StringBuilder sb = new StringBuilder(" a + 5 v 5 + 6 + 7"); String nieuw = trimOriginal(sb); System.out.println(nieuw); if(nieuw.matches("[a-zA-Z ]*\\d+.*")){ System.out.println(nieuw); }else { System.out.println("contains illegal charters"); } public static String trimOriginal(StringBuilder sb) { return sb.toString().trim(); } i want print hier also a and v.
can somebody help me
hiercoming from? Also, as written, your code will simply output an error when there are characters it does not like..a + 5 v 5 + 6 + 7?