Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I understand that parsing .json with regular expression is not really a good ide

ID: 3678268 • Letter: I

Question

I understand that parsing .json with regular expression is not really a good idea but for the sake of this school assignment I would like to know what is wrong with my regular expression. I have a .json document that I read into a string called str that ends up looking like string x which I included in my code below. From there I want to extract certain fields but every time I check my regular expression using regex_match, it returns false and I get no match. Can someone tell me what is wrong with my regex?

According to the website regex101 this should work. I believe I have escaped everything properly as well so if I could get some insight it would be much appreciated. Thanks. Also the langage I'm using is C++

Explanation / Answer

replace reg with this and check if its working


("[^"]+"(line)[^\d]+(\d+)([^"]+)"(symbols?).{5}([^\"]+).{11}(position).{3}(\d+).{6}");