file reading tips

Hello forum,

I have file with the following contents

1
2
3
4
5
6
# Printer
Printer001
# Acceleration distance
0.0
# radius
0.3


What is the optimal way to read the above file content with the following condition:

The extracted value must be preceded by the pattern "# [a-z0-9]" - in other words, a hash character followed by space and then alpha-numeric characters.

The extracted value always starts with a new line.

Thanks
What should you do if there are other lines which do not adhere to this convention?
How about your fourth line not meeting pattern requirement (space inside pattern is no allowed)

Optimal way is: read first two characters. If it is "# " then read rest of the line in name variable, check if it fits pattern. If everything is okay, read next line in value variable
Topic archived. No new replies allowed.