Skip to content

Tag: escaping

How to properly split on a non escaped delimiter?

I have the following example string: with | being the delimiter and being the escape character. A proper split should look as follows: Also I need this logic to be generally applicable in case the delimiter or the escape consists out of multiple characters. I already have a regex which splits at the correct …

Java – Forward Slash Escape Character

Can anybody tell me how I use a forward slash escape character in Java. I know backward slash is but I’ve tried / and / / with no luck! Here is my code:- Thanks in advance! Answer You don’t need to escape forward slashes either in Java as a language or in regular expressions. Also note that

Java: Literal percent sign in printf statement

I’m trying to add an actual percent sign into a printf statement in Java and I’m getting the error: I can’t figure out how to put an actual percent sign into my printf? I thought using % to escape it would work, but it isn’t. Any ideas? Answer The percent sign is escaped using a percen…