Skip to content

Instantly share code, notes, and snippets.

@xkef
Last active April 20, 2019 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkef/395d51f336492523c02c08155830502b to your computer and use it in GitHub Desktop.
Save xkef/395d51f336492523c02c08155830502b to your computer and use it in GitHub Desktop.
regex.md
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Regex tricks

https://regexper.com image.svg is from there

regex visualizer

exrex: generate words from regex

regexr: teaching

http://www.pyregex.com/



- negative lookahead: ^(?!.*bar).*$

e.g.: cut out "id": n in json

^(?!.*("id": ".*.")).*$

- passwords: 

             ^(?=.*?[A-Z]{2,})  # min. 2 upper case
              (?=.*?[a-z]{2,})  # min. 2 lower case
              (?=.*?[0-9]{2,})  # min. 2 numericals
              .{8,8}$           # length between 8,8 => 8
              
              ^(?=.*?[A-Z]{2,})(?=.*?[a-z]{2,})(?=.*?[0-9]{2,})(?!.*(.).*\1).{8,8}$ 
              
              inserting (?!.*(.).*\1) constraints word to be only of unique characters
              
            (
               (
               (
                (?=.*?[A-Z]
               ).{2,}
              )
              (
                (?=.*?[a-z])
                .{2,}
              )
              (
                (?=.*?[0-9])
                .{2,}
              )
                )(?!.*(.).*\1)
            )
            .{8,8}$ 
            
            => ((((?=.*?[A-Z]).{2,})((?=.*?[a-z]).{2,})((?=.*?[0-9]).{2,}))(?!.*(.).*\1)).{8,8}$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment