Skip to content

Instantly share code, notes, and snippets.

@amirkarimi
Last active June 17, 2020 16:24
Show Gist options
  • Save amirkarimi/68aff6d8a87285d28a18ca5f934e8169 to your computer and use it in GitHub Desktop.
Save amirkarimi/68aff6d8a87285d28a18ca5f934e8169 to your computer and use it in GitHub Desktop.
My Useful Regular Expressions

My Useful Regular Expressions

The first lines are the regex to find and the last line are the replace expressions.

YAML

Convert single quoted values to double in YAML

:(\s?)'(.*)'

:$1"$2"

Escape doube quotes inside doube quoted strings in YAML

:(\s?)"(.*)([^\\])"(.*)"

:$1"$2$3\\"$4"

Needs to be run multiple times until no match is found.

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