# Format of Scripting Helpers Q&A posts ## QA Regex ### Prototype ```regex points-number">(?P\d+)[^h]+

\r?\n\s*(?P[^<]+)(?:\s*<span class="muted">\[closed\]</span>)?</h1>\s*<div class="question-poster sans-serif">\r?\n\s*<span class="muted">Asked by</span>\r?\n\s*<div class="question-poster-username">\r?\n\s*<img src="resources/avatar/(?P<quserid>\d+)" alt(?:="[^"]*")? class="loggedin-avatar" /><a href="/user/(?P<quser>\w+)" class="loggedin-name">[^<]+</a> <span class="muted small">(?P<quserscore>\d+)</span>[^f]+float-right" title="(?P<qdatetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})[^q]+question-markdown">(?P<question>(?:<p>(?:[^<]|<code>[^<]+</code>)*</p>|<pre class=[\x27"]brush: lua[\x27"]>[^<]*</pre>)*)[^I]+Id = \x27q(?P<qid>\d+)(?:.*?h3 class="wide-line-title">(?P<answercount>\d+) answers?</h3>\r?\n\s*<div class="question" id="(?P<aid>\d+)">[^b]+ber">(?P<ascore>\d+)[^A]+Accepted answer[^A]Answered by</span>\r?\n\s*<div class="question-poster-username">\r?\n\s*<img src="/resources/avatar/(?P<auserid>\d+)" alt(?:="[^"]*")? class="loggedin-avatar" /><a href="/user/(?P<auser>\w+)" class="loggedin-name">\w+</a> <span class="muted small">(?P<auserscore>\d+)[^f]float right" title="(?P<adatetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})[^q]question-markdown">(?P<answer>(?:<p>(?:[^<]|<code>[^<]+</code>)*</p>|<pre class=[\x27"]brush: lua[\x27"]>[^<]*</pre>)*))? ``` Unusable. Use [./qa_regex4.txt/](qa_regex4.txt) ### Command Requires [ripgrep](https://github.com/burntsushi/ripgrep). ``` rg -U -uuu -o --multiline-dotall -N --color never -I -f qa_regex4.txt questions \ -r '{"qscore": "$1", "title": "$2", "quserid": "$3", "quser": "$4", "quserscore": "$5", "qdatetime": "$6", "question": <<<$7<<<, "qid": "$8", "answercount": "$9", "aid": "$10", "ascore": "$11", "auserid": "$12", "auser": "$13", "auserscore": "$14", "adatetime": "$15", "answer": >>>$16>>>}' \ ``` Must replace `<<<` blocks with long, programmatically escaped content strings. Some post content includes single backslashes. All post content has many newlines. ### Entry Specification There is one entry for every asked question, so there may be no accepted answer associated with it. In that case, all of the answer's properties (from and including `"answercount"`) will be empty strings.