I’m planning on read a *.cpp file and I would like to compare each read line against a regex. I.e.
# include <iostream>
I’d like to check if this line starts with # excluding any whitespace etc, is that possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If all you need is to check that the first non-space character of a line is
#that should work:^anchor regexp to the the beginning of the line so you start checking it from the first character\sstands for space symbol (spaces, tabs, and line breaks)*means zero or more repetition of previous character (space in that case)#to make sure that first symbol after sequence (may be empty) of spaces is#How you’ll use that regexp depends on what language you’re going to use for reading and parsing that file.