Skip to content

Instantly share code, notes, and snippets.

@psenger
Last active August 9, 2023 22:41
Show Gist options
  • Save psenger/dfbcc50d66c3b854b192b05493e4d741 to your computer and use it in GitHub Desktop.
Save psenger/dfbcc50d66c3b854b192b05493e4d741 to your computer and use it in GitHub Desktop.
[Regular Expression to find all the CSS URL functions without quoted URLS] #RegEx #CSS

Regular Expression to find all the CSS URL functions without quoted URLS

to find all url css commands that do not have quoted URLs

url\(([^"'\)]+)\)
  • match case senstivie url(
  • start capture group 1
    • Match a single character not present in [^"'\)]
      • "
      • '
      • )
    • With + match previous token between one and unlimted times as many times a possible, giving back as needed ( greedy )
  • match case senstivie \)

Then the replacement would look like this

url('$1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment