Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Karaclysm119/9933d45f84d9a05b3898ead6ce7c73a6 to your computer and use it in GitHub Desktop.
Save Karaclysm119/9933d45f84d9a05b3898ead6ce7c73a6 to your computer and use it in GitHub Desktop.
regex is popping off, here's what it can do

In the context of the skyfeed builder the regex block is looking for any single match within your whole post i would hope the case sensitive flag is self explanatory and the invert flag makes it so that instead of the filter only including posts which match it's removing them

The "Target" flags are choosing what you want to be searching within, between post text, image alt text, and links. They're non-exclusive so you can choose whatever set of those 3 you'd like.

There are a few special characters to take note of in the entry to the block, "^" is the beginning of the text and "$" is the end for example "cock" will match all of the posts containing cock, "^cock" matches all posts with cock as the first 4 characters and "^cock$" only matches if the whole post is just the word cock

This mini section is kind of a whole tangent specific to individual characters

If you put a bunch of characters in brackets like this "[abcde]" it will be checking for any one of those characters which would in this case a,b,c,d,or e. if you had something like "[abc][def]" it would match any string that is an a,b, or c, then followed by a d, e, or f. some thigns that match are "ae", "bf", "cd" but something like "ab" would not.

for the alphabet and the digits you can do something like "[a-h]" to have any letter between a and h lowercase.

Using a caret(^) in front of your group negates it, so "[^abcde]" would look for all characters other than a, b, c, d, and e. there's also this whacky and gate you can use "[a-m&&[^be]]" which would take any letter between a and m, that isn't b or e.

there are some useful escape sequences for character sets:

  • "." literally any character
  • "\d" any digit(same as [0-9])
  • "\s" any whitespace character(space, tab, there are a few more, text is weird)
  • "\w" any "word" character(same as [a-zA-Z0-9_]), which are the letters, numbers and the underscore
  • "\b" any word boundary, all whitespace and most punctuation iirc(this is particularly useful if you want to match say "ass" but not -"massive" you'd put "\bass\b")

if you capitalize the letter it does the opposite of the set you're looking for. So \S is all non-whitespace characters. There are some other shorthand sequences i didn't mention that can be used and some more specific sequences to get you certain characters but they're probably unimportant and can be found pretty easily with google.

if you need to use any of the special characters which do something other than be a character you just need to use a backslash ie "\(" is the open parenthese and "\\" is the backslash itself some of them don't require a backslash if you have them inside brackets but i honestly don't have a comprehensive list and it still works with the backslash so unless you know i'd just use the backslash

if you want to match one of some list of words you use the pipe character(|) for this: "ass|titties|bikini babe|lingerie", any of "ass", "titties", "bikini babe", or "lingerie" would match(it's kind of like a comma separated list)

Now there are also some modifiers for more complicated/intricate stuff you can do with the regex.

Any single character "a", bracket group "[abc]" shorthand sequence "\s" or a phrase in parentheses "(this whole thing)" is considered a term.

For some term X you can do any of these quantifiers: 

  • X? one or zero times
  • X* zero or more times
  • X+ one or more times
  • X{n} exactly n times
  • X{n,} at least n times
  • X{n,m} at least n times but at most m times

So something like "\w+\d{3}(ass)*" would look for one or more word characters followed by 3 digits, and then "ass" any number of times in an unbroken character chain. something like "titties_are_The_Best132" would match, and so would "q666assassassass".

you can also put a question mark after any of those quantifiers so the matched string is as small as possible(i can't think of a use for this in context but if you understand what i mean and have a use go off lol).

you can do some really complicated stuff with this, for example "^((ass|titties)\s?)+$" matches any post containing only ass and/or titties with 1 or no space between them.

good luck out there, regex can do a lot, but you probably don't need to do anything crazy(i hope)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment