I write simple application in C++/Qt. And i have a text and some octal number in it. My app splits this text by spaces. And i need to check octal numbers from text. How can i select octal numbers from this text with regular expressions?
Thank you.
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.
You can use the following regex to match only octal numbers:
^,$: Anchors0: A literal0. All octal numbersbegin with a
0.[1-7]: Char class for digits from 1to 7 as only these are valid octal
digits.
*: Quantifier for zero or more of the previous thing.So basically this regex matches only those strings that have a
0in the beginning and contain one or more digits from1to7.If the leading
0requirement is not there you can use the regex: