Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. The design is very human

The design is very human

Scheduled Pinned Locked Moved Programmer Humor
16 Posts 14 Posters 4 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • satyrsack@lemmy.sdf.orgS [email protected]

    How so? I have been getting much more comfortable with it lately, but I am curious what downsides there are

    M This user is from outside of this forum
    M This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #7

    The downsides are having to relearn it every time you need to understand it.

    G 1 Reply Last reply
    17
    • cupcakezealot@piefed.blahaj.zoneC [email protected]

      not really i just meant they suck to remember how to write without looking up 🙂

      satyrsack@lemmy.sdf.orgS This user is from outside of this forum
      satyrsack@lemmy.sdf.orgS This user is from outside of this forum
      [email protected]
      wrote on last edited by [email protected]
      #8

      Here is my cheatsheet that has been very helpful. Obviously, this will not teach you how RegEx works, but is a good quick reference when I forget the exact syntax for something.

      RegExp

      Character classes

      Pattern Description
      . Any character, except newline
      \w Word
      \d Digit
      \s Whitespace
      \W Not word
      \D Not digit
      \S Not whitespace
      [abc] Any of a, b, or c
      [a-e] Characters between a and e
      [1-9] Digit between 1 and 9
      [[:print:]] Any printable character including spaces
      [^abc] Any character except a, b or c

      Anchors

      Pattern Description
      \G Start of match
      ^ Start of string *
      $ End of string *
      \A Start of string
      \Z End of string
      \z Absolute end of string
      \b A word boundary
      \B Non-word boundary
      ^abc Start with abc
      abc$ End with abc

      For multiline patterns (m flag), ^ and $ will act as start and end of line.

      Escaped characters

      Pattern Description
      \. \* \\ Escape special character used by regex
      \t Tab
      \n Newline
      \r Carriage return

      Groups

      Pattern Description
      (abc) Capture group
      (a\|b) Match a or b
      (?:abc) Match abc, but don't capture
      \1 Substituted with text matched of the 1st capturing group

      Quantifiers

      Pattern Description
      a* Match 0 or more
      a+ Match 1 or more
      a? Match 0 or 1
      a{5} Match exactly 5
      a{,3} Match up to 3
      a{3,} Match 3 or more
      a{1,3} Match between 1 and 3

      Lookahead & Lookbehind

      Pattern Description
      a(?=b) Match a in baby but not in bay
      a(?!b) Match a in Stan but not in Stab
      (?<=a)b Match b in crabs but not in cribs
      (?<!a)b Match b in fib but not in fab
      (?<![a-z])abc(?![a-z]) Match abc without any letters before/after

      ::: spoiler Raw Markdown

      # RegExp
      
      ## Character classes
      
      | Pattern       | Description                              |
      | ------------- | ---------------------------------------- |
      | `.`           | Any character, except newline            |
      | `\w`          | Word                                     |
      | `\d`          | Digit                                    |
      | `\s`          | Whitespace                               |
      | `\W`          | Not word                                 |
      | `\D`          | Not digit                                |
      | `\S`          | Not whitespace                           |
      | `[abc]`       | Any of a, b, or c                        |
      | `[a-e]`       | Characters between `a` and `e`           |
      | `[1-9]`       | Digit between `1` and `9`                |
      | `[[:print:]]` | Any printable character including spaces |
      | `[^abc]`      | Any character except `a`, `b` or `c`     |
      
      ## Anchors
      
      | Pattern | Description            |
      | ------- | ---------------------- |
      | `\G`    | Start of match         |
      | `^`     | Start of string \*     |
      | `$`     | End of string \*       |
      | `\A`    | Start of string        |
      | `\Z`    | End of string          |
      | `\z`    | Absolute end of string |
      | `\b`    | A word boundary        |
      | `\B`    | Non-word boundary      |
      | `^abc`  | Start with `abc`       |
      | `abc$`  | End with `abc`         |
      
      For multiline patterns (`m` flag), `^` and `$` will act as start and end of line.
      
      ## Escaped characters
      
      | Pattern    | Description                            |
      | ---------- | -------------------------------------- |
      | `\. \* \\` | Escape special character used by regex |
      | `\t`       | Tab                                    |
      | `\n`       | Newline                                |
      | `\r`       | Carriage return                        |
      
      ## Groups
      
      | Pattern   | Description                                              |
      | --------- | -------------------------------------------------------- |
      | `(abc)`   | Capture group                                            |
      | `(a\|b)`  | Match `a` or `b`                                         |
      | `(?:abc)` | Match `abc`, but don't capture                           |
      | `\1`      | Substituted with text matched of the 1st capturing group |
      
      
      ## Quantifiers
      
      | Pattern  | Description           |
      | -------- | --------------------- |
      | `a*`     | Match 0 or more       |
      | `a+`     | Match 1 or more       |
      | `a?`     | Match 0 or 1          |
      | `a{5}`   | Match exactly 5       |
      | `a{,3}`  | Match up to 3         |
      | `a{3,}`  | Match 3 or more       |
      | `a{1,3}` | Match between 1 and 3 |
      
      ## Lookahead & Lookbehind
      
      | Pattern                  | Description                                  |
      | ---                      | ---                                          |
      | `a(?=b)`                 | Match `a` in `baby` but not in `bay`         |
      | `a(?!b)`                 | Match `a` in `Stan` but not in `Stab`        |
      | `(?<=a)b`                | Match `b` in `crabs` but not in `cribs`      |
      | `(?<!a)b`                | Match `b` in `fib` but not in `fab`          |
      | `(?<![a-z])abc(?![a-z])` | Match `abc` without any letters before/after |
      

      :::

      1 Reply Last reply
      21
      • rmdebarc_5@piefed.zipR [email protected]
        This post did not contain any content.
        tgirlschierke@lemmy.blahaj.zoneT This user is from outside of this forum
        tgirlschierke@lemmy.blahaj.zoneT This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #9

        yandev is that you

        1 Reply Last reply
        6
        • rmdebarc_5@piefed.zipR [email protected]
          This post did not contain any content.
          Y This user is from outside of this forum
          Y This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #10

          Jr developer told to sanitize inputs to keep db secure. Comes up with this.

          M 1 Reply Last reply
          19
          • rmdebarc_5@piefed.zipR [email protected]
            This post did not contain any content.
            M This user is from outside of this forum
            M This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #11

            One time I did this thing with an internal calibration program where the user had to type floats into a text box. I set it up so that every key stroke was validated so that the string in the box had to parse as a valid number within the assigned range at all intermediate steps.

            Everyone hated that.

            mormegil@programming.devM 1 Reply Last reply
            30
            • M [email protected]

              The downsides are having to relearn it every time you need to understand it.

              G This user is from outside of this forum
              G This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #12

              Just use something like https://regex101.com/

              1 Reply Last reply
              4
              • Y [email protected]

                Jr developer told to sanitize inputs to keep db secure. Comes up with this.

                M This user is from outside of this forum
                M This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #13

                That's not the front-end job. You can do common sense stuff, but any real protection needs to be on the backend. Any front end validation is basically "plz don't hax"

                matty_r@programming.devM 1 Reply Last reply
                5
                • M [email protected]

                  One time I did this thing with an internal calibration program where the user had to type floats into a text box. I set it up so that every key stroke was validated so that the string in the box had to parse as a valid number within the assigned range at all intermediate steps.

                  Everyone hated that.

                  mormegil@programming.devM This user is from outside of this forum
                  mormegil@programming.devM This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #14

                  Add automatic normalization to the box (you know, you type "05" and it drops the leading zero, you type "0.70" and it drops the trailing zero, etc.) and it often gets completely impossible to write anything valid. Some banking apps do something similar. 🙂

                  1 Reply Last reply
                  6
                  • M [email protected]

                    That's not the front-end job. You can do common sense stuff, but any real protection needs to be on the backend. Any front end validation is basically "plz don't hax"

                    matty_r@programming.devM This user is from outside of this forum
                    matty_r@programming.devM This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #15

                    Frontend validation is for real time user feedback (without hitting the backend constantly) instead of needing to submit the form before throwing an error/warning.

                    1 Reply Last reply
                    3
                    • rmdebarc_5@piefed.zipR [email protected]
                      This post did not contain any content.
                      Z This user is from outside of this forum
                      Z This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #16

                      https://imgur.com/a/S0ZVG1T

                      1 Reply Last reply
                      2
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups