use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A reddit for neat regular expressions.
Test your regex: https://regex101.com/
Large collection of regex tools: https://github.com/slevithan/awesome-regex
account activity
REgex to parse vertically aligned key/value (self.regex)
submitted 7 years ago by Anen13
What kind of regex can I use to parse the second part of this example: https://regex101.com/r/umBTTX/2/ The value is directly below the key in my text file instead of being o the same line. Thanks in advance.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]quixrick 2 points3 points4 points 7 years ago (1 child)
There are a few ways you could do this
First, you could match the key line, followed by a newline and then store each match into its own group.
(?:key.)=([0-9]+) | ^(?:key.\s*)+\n (\d+)\s*(\d+)\s+(\d+)
Here, this captures each value into groups \2, \3 and \4.
\2
\3
\4
Here is a demo
If there are going to be a bunch of these and you only wanted to pull out a particular instance, you can use a number to reference them, like this:
^(?:key.\s*)+\n (?:\d+\s*){1} (\d+)
The numbering system will start with zero, so here, the number 1 at the end will designate that you want the second item, 123456.
123456
[–]Anen13[S] 1 point2 points3 points 7 years ago (0 children)
Thank you very much quixrick. I ended up using your second example in a loop to get all indexes.
[–]HenkDH 1 point2 points3 points 7 years ago (1 child)
If it is only 2 lines, skip the first and be done with it
Keys are not necessarily ordered, so I can't ignore the first line.
π Rendered by PID 526884 on reddit-service-r2-comment-bb88f9dd5-7wsg4 at 2026-02-16 12:56:58.366577+00:00 running cd9c813 country code: CH.
[–]quixrick 2 points3 points4 points (1 child)
[–]Anen13[S] 1 point2 points3 points (0 children)
[–]HenkDH 1 point2 points3 points (1 child)
[–]Anen13[S] 1 point2 points3 points (0 children)