Computer Science, asked by snigdha1712chandra, 11 months ago

list all the delimiters in java​

Answers

Answered by aksingh57
3

Answer:

You can use the split() method of String class from JDK to split a String based on a delimiter e.g. splitting a comma separated String on a comma, breaking a pipe delimited String on a pipe or splitting a pipe delimited String on a pipe. It's very similar to earlier examples where you have learned how to split String in Java. The only point which is important to remember is little bit knowledge of regular expression, especially when the delimiter is also a special character in regular expression e.g. pipe (|) or dot (.), as seen in how to split String by dot in Java. In those cases, you need to escape these characters e.g. instead of |, you need to pass \\| to the split method.

Alternatively, you can also use special characters inside character class i.e. inside a square bracket e.g. [|] or [.], though you need to be careful that they don't have any special meaning inside character class e.g. pipe and dot doesn't have any special meaning inside character class but ^ does have.

Similar questions