How do i search a string for a newline character? Both of the below seem to be returning -1….!
theJ = line.IndexOf(Environment.NewLine);
OR
theJ = line.IndexOf('\n');
The string it’s searching is “yo\n”
the string i’m parsing contains this “printf(“yo\n”);”
the string i see contained during the comparison is this: “\tprintf(\”yo\n\”);”
Are you sure you’re searching
yo\nand notyo\\n?Edit
Based on your update, I can see that I guessed correctly. If your string says:
… then this does not contain a newline character. If it did, it would look like this:
What it actually has is an escaped newline character, or in other words, a backslash character followed by an ‘n’. That’s why the string you’re seeing when you debug is
"\tprintf(\"yo\\n\");". If you want to find this character combination, you can use:For example: