I have to check for character sequences like \chapter{Introduction} from the strings read from a file. To do this I have to first check for the occurence of backslash.
This is what I did
final char[] chars = strLine.toCharArray();
char c;
for(int i = 0; i<chars.length; i++ ){
c = chars[i];
if(c == '\' ) {
}
}
But the backslash is treated as an escape sequence rather than a character.
Any help on how to this would be much appreciated.
The backward slash is an escape character. If you want to represent a real backslach, you have to use two backslashes (it's then escaping itself). Further, you also need to denote characters by singlequotes, not by doublequotes. So, this should work:
if (c == '\\')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With