Android: Search and replace in a string with a quoted regex..


/ Published in: Java
Save to your folder(s)

Sometimes you *don't* want to use a regex in a String.replace method. You need to 'quote' the special regex characters with Pattern.quote("string")


Copy this code and paste it in your HTML
  1. indexString.replaceAll(Pattern.quote(notARegex), replacement );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.