Replace\remove last occurrence of a string using regular expressions

Try this regex (^.+)b(.+$)

Example (Remove the last b character)

    System.out.println("1abchhhabcjjjabc".replaceFirst("(^.+)b(.+$)", "$1$2"));

Outputs (Notice the underlined portion of string)


   1abchhhabcjjjac

Comments

Popular posts from this blog

Testing SOAP services using pingdom