Home > Contents > Index >
Expanded TOC   |    Accordion TOC   |    Annotated TOC   |    Index

 

Utilities.replaceAll

Replaces all occurrences in a string of a specified substring with a new string.

Syntax

Parameters

source
The source string to be modified. NULL or empty returns the same string.

what
The substring to replace. To leave the source string unaltered, set what to null.

with
The replacement text. To erase the substring identified by what, set with to null.

Description

The replaceAll method replaces all occurrences in a string of a specified substring with a new string.

Returns

Returns the new string.

Example

The following code fragment replaces both occurrences of red with green:

The resulting value of repStr will be:

 

  Home > Contents > Index >

Oracle JAVA Reference
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.