Category: String

How to replace backslashes in java 0

How to replace backslashes in java

The String#replaceAll() interprets the argument as a regular expression. The \ is an escape character in both String and regex. You need to double-escape it for regex: string.replaceAll(“\\\\”, “\\\\\\\\”); But you don’t necessarily need...

How much memory does a string consume in Java 0

How much memory does a string consume in Java

Understanding String memory usage To understand the above calculation, we need to start by looking at the fields on a String object. A String contains the following: a char array— thus a separate object—...

How to split string which has dollars($) 0

How to split string which has dollars($)

Suppose we have a string data1$$$data2$$$data3, how will you split it? If you use str.split(“$$$”) it will not split the string and instead return the same string only. The split function takes a regular...