I want to replace Html.fromHtml(" ") + "| Guys hi " + Pattern.compile("\\d+") with a "hey". But, my code doesn't want to do that :/ What should I change?
My code:
myString.replace(Html.fromHtml(" ") + "| Guys hi " + Pattern.compile("\\d+"), "hey");
Explanation:
" "represents a space in HTMLPattern.compile("\\d+")finds any number at the end of string.
Pattern.compile("\\d+")supposed to do? Regex (or Patterns) is for text matching/validating... It won't be turned into a number/text.Pattern.compile("\\d+")only creates pattern which describes one or more digits, but it doesn't automatically find it. It is your job to decide how to use it. From what I see you could be looking forreplaceAll(regex, replacement).