Replaces the specified character and returns the result token. @param token token to be checked @param search the character to be replaced @param replace the new character @return resulting token
(final byte[] token, final int search, final int replace)
| 1099 | * @return resulting token |
| 1100 | */ |
| 1101 | public static byte[] replace(final byte[] token, final int search, final int replace) { |
| 1102 | if(!contains(token, search)) return token; |
| 1103 | |
| 1104 | final TokenBuilder tb = new TokenBuilder(token.length); |
| 1105 | forEachCp(token, cp -> tb.add(cp == search ? replace : cp)); |
| 1106 | return tb.finish(); |
| 1107 | } |
| 1108 | |
| 1109 | /** |
| 1110 | * Removes leading and trailing whitespace from the specified token. |