Skip to content

Instantly share code, notes, and snippets.

@AlexxNica
Created March 19, 2023 15:59
Show Gist options
  • Save AlexxNica/899586585beb08014573b4695c445dd4 to your computer and use it in GitHub Desktop.
Save AlexxNica/899586585beb08014573b4695c445dd4 to your computer and use it in GitHub Desktop.
VSCode Tips

VSCode Tips

Delete Duplicate Lines

Find: ^(.*)(\r?\n\1)+$

Replace: $1

Remove empty lines

Find: {2}

Replace: ``

From "enable-ftp@1", to ["enable-ftp", "1"],

Find: ^.*(".*)@(.)(.*)$

Replace: [$1", "$2"],

Find non-compliant hostnames. (from https://regexlib.com/REDetails.aspx?regexp_id=391)

Find: ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$

Find: ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$

Hostname FQDN validation (from https://www.regextester.com/103452)

(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)

Get only domains from URLs

(.*://((?!/).)*)

://(.[^/]+)

Select URL by scheme grouping

Find: ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

To SURT

Find: ^(.+)\.(.+)\.(.+)\.(.+)\.(.+)\.(.+)\.(.+)\.(((?!\)).)+)$

Replace: $8,$7,$6,$5,$4,$3,$2,$1)

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