Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rindeal/529861d6c41ab62c5e981849d50c4994 to your computer and use it in GitHub Desktop.
Save rindeal/529861d6c41ab62c5e981849d50c4994 to your computer and use it in GitHub Desktop.

Upstream Tests

Upstream RegEx Patter

Regular Expression
(?x)
  ^

  (?:

    (
      (?:\\(\S+\)\s*)?
      (?:
        sh\S*?                   |
        \w+\S+[@:]\S+(?:\s+\S+)? |
        \[\S+?[@:][^\n]+?\].*?
      )
    )

    \s*

  )?

  (
    [>$#%] |
    \p{Greek}
  )

  \s+
  (.*)

  $
$ foo str 'str' "str" $var '$var' "$var" str$var 'str$var' "str$var" \$str "\$str" s${var}s
foo "bar" baz

$ ## 

$ foo "bar"
Lorem "Ipsum"

> foo "bar"
Lorem "Ipsum"

# foo "bar"
Lorem "Ipsum"

% foo "bar"
Lorem "Ipsum"foo "bar"
Lorem "Ipsum"foo "bar"
Lorem "Ipsum"

μ ## Greek alphabet also works

λ foo "bar"
Lorem "Ipsum"

$ ## `user@machine` prefixes work also
user@machine $ echo foo "bar"
Lorem "Ipsum"

$ ## Even complex prefixes
(venv) machine:pwd user$ echo foo "bar"
Lorem "Ipsum"

(.) a.:. .$ echo foo
(.)a.:. .$ echo foo
a.:. .$ echo foo
(.) > .
sh. > .
.@: > .
[.@:] > .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment