Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active December 27, 2022 01:53
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 Beyarz/1348e87397d9a7dc803de80f1c0f91fd to your computer and use it in GitHub Desktop.
Save Beyarz/1348e87397d9a7dc803de80f1c0f91fd to your computer and use it in GitHub Desktop.
regex

Regex cheatsheet

[^\s]+$

[Thu May 14 11:08:28 2020] 1.3.3.7 root emerald
[Thu May 14 11:08:29 2020] 1.3.3.7 root carrie
[Thu May 14 11:08:31 2020] 1.3.3.7 root wangfei
[Thu May 14 11:08:32 2020] 1.3.3.7 root a1314521
[Thu May 14 11:08:33 2020] 1.3.3.7 root australia
[Thu May 14 11:08:35 2020] 1.3.3.7 root john
[Thu May 14 11:08:36 2020] 1.3.3.7 root nadine
[Thu May 14 11:08:38 2020] 1.3.3.7 root 1235
[Thu May 14 11:08:39 2020] 1.3.3.7 root music
[Thu May 14 11:08:56 2020] 1.3.3.7 root 1QaZ2WsX

\w{1,3}.\w{1,3}.\w{1,3}.\w{1,3}

[Thu May 14 11:08:28 2020] 1.3.3.7 root emerald
[Thu May 14 11:08:29 2020] 1.3.3.7 root carrie
[Thu May 14 11:08:31 2020] 1.3.3.7 root wangfei
[Thu May 14 11:08:32 2020] 1.3.3.7 root a1314521
[Thu May 14 11:08:33 2020] 1.3.3.7 root australia
[Thu May 14 11:08:35 2020] 1.3.3.7 root john
[Thu May 14 11:08:36 2020] 1.3.3.7 root nadine
[Thu May 14 11:08:38 2020] 1.3.3.7 root 1235
[Thu May 14 11:08:39 2020] 1.3.3.7 root music
[Thu May 14 11:08:56 2020] 1.3.3.7 root 1QaZ2WsX

Add prefix & suffix

Find: \w.+ Replace: able:"$&"

Case-insensetive

/(?i)alex/

rObInaLexMiCHael
ALEXmichAEL
mIchaelRobINaleX

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