Reputation: 131
I am trying to come up with a regex expression that can ignore any character in a line (after I read my relevant input). In a way, its treating the characters after a certain point in the txt file as a comment, but the comment is 'anything' but the relevant information I need. Here's what I have and its worked, but am wondering if there's a more elegant way to handle this:
fscanf(input_file, "%*[a-zA-Z .^$*+?()[{\'\" \t]", temp_char)
temp_char
is a char* buffer.
Thanks
Upvotes: 1
Views: 4085
Reputation: 144951
If you want to consume every character different from \n
and the final \n
, use these statements:
fscanf(input_file, "%*[^\n]");
fscanf(input_file, "%*c");
The first ignores all characters different from \n
, but fails if there are none.
The second consumes the \n
character.
Upvotes: 3