Let\'s say I\'m parsing a file, which uses ; as the comment character. I don\'t want to parse comments. So if I a line looks like this:
;
example.com.
I'd recommend saying
line.split(";")[0]
which will give you a string of all characters up to but not including the first ";" character. If no ";" character is present, then it will give you the entire line.