diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index f1524427816ebb9ba5137ca106319399c56c6535..f579d5664bc6da5f98b94db45b06a0a77d6c072a 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -171,7 +171,7 @@ def __init__(self, root, **kwargs):
             "${COMPILERNAME}-${COMPILERVER}/"
             "${PACKAGE}-${VERSION}-${HASH}")
         if self.hash_len is not None:
-            if re.search('\${HASH:\d+}', self.path_scheme):
+            if re.search(r'\${HASH:\d+}', self.path_scheme):
                 raise InvalidDirectoryLayoutParametersError(
                     "Conflicting options for installation layout hash length")
             self.path_scheme = self.path_scheme.replace(
diff --git a/lib/spack/spack/graph.py b/lib/spack/spack/graph.py
index 5c8c60a3bbc7be0a91fcfb5ef4fd55060cd2b664..8c481084ae408e3a7308615a7f9df5ccb7d4e3d2 100644
--- a/lib/spack/spack/graph.py
+++ b/lib/spack/spack/graph.py
@@ -3,7 +3,7 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
-"""Functions for graphing DAGs of dependencies.
+r"""Functions for graphing DAGs of dependencies.
 
 This file contains code for graphing DAGs of software packages
 (i.e. Spack specs).  There are two main functions you probably care
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index 8e9a48208c19b385e31cfd626cbef3875a4bfe1a..a559ae64951e0a8e3be129b1aa49a3751791b1f8 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -120,7 +120,7 @@ def macho_get_paths(path_name):
         if match:
             lhs = match.group(1).lstrip().rstrip()
             rhs = match.group(2)
-            match2 = re.search('(.*) \(.*\)', rhs)
+            match2 = re.search(r'(.*) \(.*\)', rhs)
             if match2:
                 rhs = match2.group(1)
             if lhs == 'cmd':
diff --git a/lib/spack/spack/test/cmd/license.py b/lib/spack/spack/test/cmd/license.py
index bc77cad09614f8596a1ca31d916979f8225c7eb8..fe02cb18a52cb3b95f74504222f7c79ad5f8d385 100644
--- a/lib/spack/spack/test/cmd/license.py
+++ b/lib/spack/spack/test/cmd/license.py
@@ -61,8 +61,8 @@ def test_verify(tmpdir):
     assert str(old_lgpl_header) in out
     assert str(correct_header) not in out
     assert '3 improperly licensed files' in out
-    assert re.search('files with no SPDX-License-Identifier:\s*1', out)
-    assert re.search('files with wrong SPDX-License-Identifier:\s*1', out)
-    assert re.search('files with old license header:\s*1', out)
+    assert re.search(r'files with no SPDX-License-Identifier:\s*1', out)
+    assert re.search(r'files with wrong SPDX-License-Identifier:\s*1', out)
+    assert re.search(r'files with old license header:\s*1', out)
 
     assert license.returncode == 1
diff --git a/lib/spack/spack/test/pattern.py b/lib/spack/spack/test/pattern.py
index 1e3fbdaf0e2f7b7d593d2a47c0695f305cf6e380..406915bdf08ec5da950444fce52a42da1ac4cc28 100644
--- a/lib/spack/spack/test/pattern.py
+++ b/lib/spack/spack/test/pattern.py
@@ -15,10 +15,10 @@ class Base:
         counter = 0
 
         def add(self):
-            raise NotImplemented('add not implemented')
+            raise NotImplementedError('add not implemented')
 
         def subtract(self):
-            raise NotImplemented('subtract not implemented')
+            raise NotImplementedError('subtract not implemented')
 
     return Base
 
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
index 5819d07e1ad445cba8b49c8a54ae74f2c622f6ea..387c8c957d4acdd1b82b499515a6628e621faa26 100644
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -44,7 +44,7 @@
 # "path" seemed like the most generic term.
 #
 def find_list_url(url):
-    """Finds a good list URL for the supplied URL.
+    r"""Finds a good list URL for the supplied URL.
 
     By default, returns the dirname of the archive path.
 
@@ -148,81 +148,81 @@ def strip_version_suffixes(path):
 
     suffix_regexes = [
         # Download type
-        '[Ii]nstall',
-        'all',
-        'code',
-        'src(_0)?',
-        '[Ss]ources?',
-        'file',
-        'full',
-        'single',
-        'public',
-        'with[a-zA-Z_-]+',
-        'bin',
-        'binary',
-        'run',
-        '[Uu]niversal',
-        'jar',
-        'complete',
-        'dynamic',
-        'oss',
-        'gem',
-        'tar',
-        'sh',
+        r'[Ii]nstall',
+        r'all',
+        r'code',
+        r'src(_0)?',
+        r'[Ss]ources?',
+        r'file',
+        r'full',
+        r'single',
+        r'public',
+        r'with[a-zA-Z_-]+',
+        r'bin',
+        r'binary',
+        r'run',
+        r'[Uu]niversal',
+        r'jar',
+        r'complete',
+        r'dynamic',
+        r'oss',
+        r'gem',
+        r'tar',
+        r'sh',
 
         # Download version
-        'release',
-        'stable',
-        '[Ff]inal',
-        'rel',
-        'orig',
-        'dist',
-        '\+',
+        r'release',
+        r'stable',
+        r'[Ff]inal',
+        r'rel',
+        r'orig',
+        r'dist',
+        r'\+',
 
         # License
-        'gpl',
+        r'gpl',
 
         # Arch
         # Needs to come before and after OS, appears in both orders
-        'ia32',
-        'intel',
-        'amd64',
-        'x64',
-        'x86[_-]64',
-        'x86',
-        'i[36]86',
-        'ppc64(le)?',
-        'armv?(7l|6l|64)',
+        r'ia32',
+        r'intel',
+        r'amd64',
+        r'x64',
+        r'x86[_-]64',
+        r'x86',
+        r'i[36]86',
+        r'ppc64(le)?',
+        r'armv?(7l|6l|64)',
 
         # OS
-        '[Ll]inux(_64)?',
-        '[Uu]ni?x',
-        '[Ss]un[Oo][Ss]',
-        '[Mm]ac[Oo][Ss][Xx]?',
-        '[Oo][Ss][Xx]',
-        '[Dd]arwin(64)?',
-        '[Aa]pple',
-        '[Ww]indows',
-        '[Ww]in(64|32)?',
-        '[Cc]ygwin(64|32)?',
-        '[Mm]ingw',
+        r'[Ll]inux(_64)?',
+        r'[Uu]ni?x',
+        r'[Ss]un[Oo][Ss]',
+        r'[Mm]ac[Oo][Ss][Xx]?',
+        r'[Oo][Ss][Xx]',
+        r'[Dd]arwin(64)?',
+        r'[Aa]pple',
+        r'[Ww]indows',
+        r'[Ww]in(64|32)?',
+        r'[Cc]ygwin(64|32)?',
+        r'[Mm]ingw',
 
         # Arch
         # Needs to come before and after OS, appears in both orders
-        'ia32',
-        'intel',
-        'amd64',
-        'x64',
-        'x86[_-]64',
-        'x86',
-        'i[36]86',
-        'ppc64(le)?',
-        'armv?(7l|6l|64)?',
+        r'ia32',
+        r'intel',
+        r'amd64',
+        r'x64',
+        r'x86[_-]64',
+        r'x86',
+        r'i[36]86',
+        r'ppc64(le)?',
+        r'armv?(7l|6l|64)?',
 
         # PyPI
-        '[._-]py[23].*\.whl',
-        '[._-]cp[23].*\.whl',
-        '[._-]win.*\.exe',
+        r'[._-]py[23].*\.whl',
+        r'[._-]cp[23].*\.whl',
+        r'[._-]win.*\.exe',
     ]
 
     for regex in suffix_regexes:
@@ -274,22 +274,22 @@ def strip_name_suffixes(path, version):
         str(version) + '.*',
 
         # Download type
-        'install',
-        'src',
-        '(open)?[Ss]ources?',
-        '[._-]archive',
-        '[._-]std',
+        r'install',
+        r'src',
+        r'(open)?[Ss]ources?',
+        r'[._-]archive',
+        r'[._-]std',
 
         # Download version
-        'release',
-        'snapshot',
-        'distrib',
+        r'release',
+        r'snapshot',
+        r'distrib',
 
         # VCS
-        '0\+bzr',
+        r'0\+bzr',
 
         # License
-        'gpl',
+        r'gpl',
     ]
 
     for regex in suffix_regexes:
@@ -799,7 +799,7 @@ def wildcard_version(path):
 
     # Replace each version with a generic capture group to find versions
     # and escape everything else so it's not interpreted as a regex
-    result = '(\d.*)'.join(re.escape(vp) for vp in vparts)
+    result = r'(\d.*)'.join(re.escape(vp) for vp in vparts)
 
     return result
 
diff --git a/var/spack/repos/builtin/packages/chombo/package.py b/var/spack/repos/builtin/packages/chombo/package.py
index 0044edf2402fdffb6750bc0dce16a18fd9956641..332dae343fbcf58e14f18477d7365b4f24c6f258 100644
--- a/var/spack/repos/builtin/packages/chombo/package.py
+++ b/var/spack/repos/builtin/packages/chombo/package.py
@@ -45,7 +45,7 @@ def edit(self, spec, prefix):
 
         # Set fortran name mangling in Make.defs
         defs_file = FileFilter('./lib/mk/Make.defs')
-        defs_file.filter('^\s*#\s*cppcallsfort\s*=\s*',
+        defs_file.filter(r'^\s*#\s*cppcallsfort\s*=\s*',
                          'cppcallsfort = -DCH_FORT_UNDERSCORE')
 
         # Set remaining variables in Make.defs.local
@@ -57,53 +57,53 @@ def edit(self, spec, prefix):
         defs_file = FileFilter('./lib/mk/Make.defs.local')
 
         # Unconditional settings
-        defs_file.filter('^\s*#\s*DEBUG\s*=\s*', 'DEBUG = FALSE')
-        defs_file.filter('^\s*#\s*OPT\s*=\s*', 'OPT = TRUE')
-        defs_file.filter('^\s*#\s*PIC\s*=\s*', 'PIC = TRUE')
+        defs_file.filter(r'^\s*#\s*DEBUG\s*=\s*', 'DEBUG = FALSE')
+        defs_file.filter(r'^\s*#\s*OPT\s*=\s*', 'OPT = TRUE')
+        defs_file.filter(r'^\s*#\s*PIC\s*=\s*', 'PIC = TRUE')
         # timer code frequently fails compiles. So disable it.
-        defs_file.filter('^\s*#\s*USE_TIMER\s*=\s*', 'USE_TIMER = FALSE')
+        defs_file.filter(r'^\s*#\s*USE_TIMER\s*=\s*', 'USE_TIMER = FALSE')
 
         # LAPACK setup
         lapack_blas = spec['lapack'].libs + spec['blas'].libs
-        defs_file.filter('^\s*#\s*USE_LAPACK\s*=\s*', 'USE_LAPACK = TRUE')
+        defs_file.filter(r'^\s*#\s*USE_LAPACK\s*=\s*', 'USE_LAPACK = TRUE')
         defs_file.filter(
-            '^\s*#\s*lapackincflags\s*=\s*',
+            r'^\s*#\s*lapackincflags\s*=\s*',
             'lapackincflags = -I%s' % spec['lapack'].prefix.include)
         defs_file.filter(
-            '^\s*#\s*syslibflags\s*=\s*',
+            r'^\s*#\s*syslibflags\s*=\s*',
             'syslibflags = %s' % lapack_blas.ld_flags)
 
         # Compilers and Compiler flags
-        defs_file.filter('^\s*#\s*CXX\s*=\s*', 'CXX = %s' % spack_cxx)
-        defs_file.filter('^\s*#\s*FC\s*=\s*', 'FC = %s' % spack_fc)
+        defs_file.filter(r'^\s*#\s*CXX\s*=\s*', 'CXX = %s' % spack_cxx)
+        defs_file.filter(r'^\s*#\s*FC\s*=\s*', 'FC = %s' % spack_fc)
         if '+mpi' in spec:
             defs_file.filter(
-                '^\s*#\s*MPICXX\s*=\s*',
+                r'^\s*#\s*MPICXX\s*=\s*',
                 'MPICXX = %s' % self.spec['mpi'].mpicxx)
 
         # Conditionally determined settings
         defs_file.filter(
-            '^\s*#\s*MPI\s*=\s*',
+            r'^\s*#\s*MPI\s*=\s*',
             'MPI = %s' % ('TRUE' if '+mpi' in spec else 'FALSE'))
         defs_file.filter(
-            '^\s*#\s*DIM\s*=\s*',
+            r'^\s*#\s*DIM\s*=\s*',
             'DIM = %s' % spec.variants['dims'].value)
 
         # HDF5 settings
         if '+hdf5' in spec:
-            defs_file.filter('^\s*#\s*USE_HDF5\s*=\s*', 'USE_HDF5 = TRUE')
+            defs_file.filter(r'^\s*#\s*USE_HDF5\s*=\s*', 'USE_HDF5 = TRUE')
             defs_file.filter(
-                '^\s*#\s*HDFINCFLAGS\s*=.*',
+                r'^\s*#\s*HDFINCFLAGS\s*=.*',
                 'HDFINCFLAGS = -I%s' % spec['hdf5'].prefix.include)
             defs_file.filter(
-                '^\s*#\s*HDFLIBFLAGS\s*=.*',
+                r'^\s*#\s*HDFLIBFLAGS\s*=.*',
                 'HDFLIBFLAGS = %s' % spec['hdf5'].libs.ld_flags)
             if '+mpi' in spec:
                 defs_file.filter(
-                    '^\s*#\s*HDFMPIINCFLAGS\s*=.*',
+                    r'^\s*#\s*HDFMPIINCFLAGS\s*=.*',
                     'HDFMPIINCFLAGS = -I%s' % spec['hdf5'].prefix.include)
                 defs_file.filter(
-                    '^\s*#\s*HDFMPILIBFLAGS\s*=.*',
+                    r'^\s*#\s*HDFMPILIBFLAGS\s*=.*',
                     'HDFMPILIBFLAGS = %s' % spec['hdf5'].libs.ld_flags)
 
     def build(self, spec, prefix):
diff --git a/var/spack/repos/builtin/packages/ldc/package.py b/var/spack/repos/builtin/packages/ldc/package.py
index ba027538bdf302480b44dc0945326435b3aa9dfd..a1768d71b9115144574b438e7fa9840b2b76882b 100644
--- a/var/spack/repos/builtin/packages/ldc/package.py
+++ b/var/spack/repos/builtin/packages/ldc/package.py
@@ -59,7 +59,7 @@ def add_rpath_to_conf(self):
 
         config_file = join_path(self.prefix.etc, 'ldc2.conf')
 
-        search_for = 'switches = \['
+        search_for = r'switches = \['
         substitute_with = 'switches = [\n' + \
                           '        "-L-rpath={0}",'.format(self.prefix.lib)
 
diff --git a/var/spack/repos/builtin/packages/libceed/package.py b/var/spack/repos/builtin/packages/libceed/package.py
index e9eea919e2eb5e495d42a6e04bc70b938ab9ff72..578da421812a1df7d2df8183ac486f848c82207d 100644
--- a/var/spack/repos/builtin/packages/libceed/package.py
+++ b/var/spack/repos/builtin/packages/libceed/package.py
@@ -51,10 +51,11 @@ def install(self, spec, prefix):
         install('ceed.h', prefix.include)
         mkdirp(prefix.lib)
         install('libceed.%s' % dso_suffix, prefix.lib)
-        filter_file('^prefix=.*$', 'prefix=%s' % prefix, 'ceed.pc')
-        filter_file('^includedir=\$\{prefix\}$',
+        filter_file(r'^prefix=.*$', 'prefix=%s' % prefix, 'ceed.pc')
+        filter_file(r'^includedir=\$\{prefix\}$',
                     'includedir=${prefix}/include', 'ceed.pc')
-        filter_file('^libdir=\$\{prefix\}$', 'libdir=${prefix}/lib', 'ceed.pc')
-        filter_file('Version:.*$', 'Version: 0.1', 'ceed.pc')
+        filter_file(r'^libdir=\$\{prefix\}$',
+                    'libdir=${prefix}/lib', 'ceed.pc')
+        filter_file(r'Version:.*$', 'Version: 0.1', 'ceed.pc')
         mkdirp(prefix.lib.pkgconfig)
         install('ceed.pc', prefix.lib.pkgconfig)
diff --git a/var/spack/repos/builtin/packages/meraculous/package.py b/var/spack/repos/builtin/packages/meraculous/package.py
index 18cdd064c8527df0c69380f69ca61461a182899e..8e44be55967a0e03ab377b4d9f4125a84334aef5 100644
--- a/var/spack/repos/builtin/packages/meraculous/package.py
+++ b/var/spack/repos/builtin/packages/meraculous/package.py
@@ -26,7 +26,7 @@ class Meraculous(CMakePackage):
 
     def patch(self):
         edit = FileFilter('CMakeLists.txt')
-        edit.filter("-static-libstdc\+\+", "")
+        edit.filter(r"-static-libstdc\+\+", "")
 
     def setup_environment(self, spack_env, run_env):
         run_env.set('MERACULOUS_ROOT', self.prefix)
diff --git a/var/spack/repos/builtin/packages/multitail/package.py b/var/spack/repos/builtin/packages/multitail/package.py
index 93c17279e0a1c0f2eff118e2e74dd10f5a2bea2d..0f6cd8a46bd1761f4661f31f3d63b585afd17588 100644
--- a/var/spack/repos/builtin/packages/multitail/package.py
+++ b/var/spack/repos/builtin/packages/multitail/package.py
@@ -33,11 +33,11 @@ def edit(self, spec, prefix):
 
         nc_include_flags = spec['ncurses'].headers.include_flags
         nc_ld_flags = spec['ncurses'].libs.ld_flags
-        makefile.filter('CFLAGS\+=', 'CFLAGS+={0} '.format(nc_include_flags))
-        makefile.filter('LDFLAGS\+=', 'LDFLAGS+={0} '.format(nc_ld_flags))
+        makefile.filter(r'CFLAGS\+=', 'CFLAGS+={0} '.format(nc_include_flags))
+        makefile.filter(r'LDFLAGS\+=', 'LDFLAGS+={0} '.format(nc_ld_flags))
 
         # Copy the conf file directly into place (don't worry about
         # overwriting an existing file...)
         kwargs = {'ignore_absent': False, 'backup': False, 'string': True}
-        makefile.filter('cp multitail.conf $(CONFIG_FILE).new',
+        makefile.filter(r'cp multitail.conf $(CONFIG_FILE).new',
                         'cp multitail.conf $(CONFIG_FILE)', **kwargs)
diff --git a/var/spack/repos/builtin/packages/mumps/package.py b/var/spack/repos/builtin/packages/mumps/package.py
index f054e094e2edc83a779d3a54c7ebdb7378acd563..234708f7a2b9df20eb876b0beca0fd704ebfac40 100644
--- a/var/spack/repos/builtin/packages/mumps/package.py
+++ b/var/spack/repos/builtin/packages/mumps/package.py
@@ -233,8 +233,8 @@ def write_makefile_inc(self):
                 # When building libpord, read AR from Makefile.inc instead of
                 # going through the make command line - this prevents various
                 # problems with the substring "$$@".
-                filter_file(' AR="\$\(AR\)"', '', 'Makefile')
-                filter_file('^(INCLUDES = -I../include)',
+                filter_file(r' AR="\$\(AR\)"', '', 'Makefile')
+                filter_file(r'^(INCLUDES = -I../include)',
                             '\\1\ninclude ../../Makefile.inc',
                             join_path('PORD', 'lib', 'Makefile'))
 
diff --git a/var/spack/repos/builtin/packages/nek5000/package.py b/var/spack/repos/builtin/packages/nek5000/package.py
index dbd19eb55444d69940a1fdd56df600425bb88584..a522af8cf0f7d3594c89ccbb181b302ba51195e4 100644
--- a/var/spack/repos/builtin/packages/nek5000/package.py
+++ b/var/spack/repos/builtin/packages/nek5000/package.py
@@ -158,7 +158,7 @@ def install(self, spec, prefix):
 
             if self.compiler.name in ['xl', 'xl_r']:
                 # Use '-qextname' when compiling mxm.f
-                filter_file('\$\(OLAGS\)', '-qextname $(OLAGS)',
+                filter_file(r'\$\(OLAGS\)', '-qextname $(OLAGS)',
                             join_path('postnek', 'makefile'))
             # Define 'rename_' function that calls 'rename'
             with open(join_path('postnek', 'xdriver.c'), 'a') as xdriver:
diff --git a/var/spack/repos/builtin/packages/pacbio-daligner/package.py b/var/spack/repos/builtin/packages/pacbio-daligner/package.py
index 534716d005b03dc0da689b3468b451b72a4dbb65..07738d14ee49b23d23920eae20cbdfdd841178e3 100644
--- a/var/spack/repos/builtin/packages/pacbio-daligner/package.py
+++ b/var/spack/repos/builtin/packages/pacbio-daligner/package.py
@@ -21,7 +21,7 @@ class PacbioDaligner(MakefilePackage):
     def edit(self, spec, prefix):
         mkdir(prefix.bin)
         makefile = FileFilter('Makefile')
-        makefile.filter('DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
+        makefile.filter(r'DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
         gmf = FileFilter('GNUmakefile')
-        gmf.filter('rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
+        gmf.filter(r'rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
                    'cp ${ALL} ' + prefix.bin)
diff --git a/var/spack/repos/builtin/packages/pacbio-damasker/package.py b/var/spack/repos/builtin/packages/pacbio-damasker/package.py
index f41440570a0096135886e6baa307635071e37bb3..d904e3ece2fa290c0a35486d56afa17517983a9a 100644
--- a/var/spack/repos/builtin/packages/pacbio-damasker/package.py
+++ b/var/spack/repos/builtin/packages/pacbio-damasker/package.py
@@ -20,7 +20,7 @@ class PacbioDamasker(MakefilePackage):
     def edit(self, spec, prefix):
         mkdirp(prefix.bin)
         makefile = FileFilter('Makefile')
-        makefile.filter('DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
+        makefile.filter(r'DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
         gmf = FileFilter('GNUmakefile')
-        gmf.filter('rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
+        gmf.filter(r'rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
                    'cp ${ALL} ' + prefix.bin)
diff --git a/var/spack/repos/builtin/packages/pacbio-dazz-db/package.py b/var/spack/repos/builtin/packages/pacbio-dazz-db/package.py
index 2e2abca958c8b7736c6fb93535f140eca4034b02..0ccb68842b635c7242678183d35ea1f49c760564 100644
--- a/var/spack/repos/builtin/packages/pacbio-dazz-db/package.py
+++ b/var/spack/repos/builtin/packages/pacbio-dazz-db/package.py
@@ -23,12 +23,12 @@ def edit(self, spec, prefix):
         mkdirp(prefix.lib)
         mkdirp(prefix.include)
         makefile = FileFilter('Makefile')
-        makefile.filter('DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
+        makefile.filter(r'DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
         gmf = FileFilter('GNUmakefile')
-        gmf.filter('rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
+        gmf.filter(r'rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
                    'cp ${ALL} ' + prefix.bin)
-        gmf.filter('rsync\s*-av\s*libdazzdb.*\s*\$\{PREFIX\}/lib',
+        gmf.filter(r'rsync\s*-av\s*libdazzdb.*\s*\$\{PREFIX\}/lib',
                    'cp libdazzdb.* ' + prefix.lib)
-        gmf.filter(('rsync\s*-av\s*\$\(wildcard\s*\$\{THISDIR\}/\*.h'
-                    '\)\s*\$\{PREFIX\}/include'),
+        gmf.filter((r'rsync\s*-av\s*\$\(wildcard\s*\$\{THISDIR\}/\*.h'
+                    r'\)\s*\$\{PREFIX\}/include'),
                    'cp *.h ' + prefix.include)
diff --git a/var/spack/repos/builtin/packages/pacbio-dextractor/package.py b/var/spack/repos/builtin/packages/pacbio-dextractor/package.py
index 831f64cd673c98edafed0b26932adfe666abf694..9fea4ecd78eaf28ea9819de1d5abcf6206c59e13 100644
--- a/var/spack/repos/builtin/packages/pacbio-dextractor/package.py
+++ b/var/spack/repos/builtin/packages/pacbio-dextractor/package.py
@@ -21,10 +21,10 @@ class PacbioDextractor(MakefilePackage):
     def edit(self, spec, prefix):
         mkdirp(prefix.bin)
         makefile = FileFilter('Makefile')
-        makefile.filter('PATH_HDF5\s*=\s*/sw/apps/hdf5/current',
+        makefile.filter(r'PATH_HDF5\s*=\s*/sw/apps/hdf5/current',
                         'PATH_HDF5 = ' + spec['hdf5'].prefix)
-        makefile.filter('PATH_HDF5\*s=\s*/usr/local/hdf5', '')
-        makefile.filter('DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
+        makefile.filter(r'PATH_HDF5\*s=\s*/usr/local/hdf5', '')
+        makefile.filter(r'DEST_DIR\s*=\s*~/bin', 'DEST_DIR = ' + prefix.bin)
         gmf = FileFilter('GNUmakefile')
-        gmf.filter('rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
+        gmf.filter(r'rsync\s*-av\s*\$\{ALL\}\s*\$\{PREFIX\}/bin',
                    'cp ${ALL} ' + prefix.bin)
diff --git a/var/spack/repos/builtin/packages/pixman/package.py b/var/spack/repos/builtin/packages/pixman/package.py
index dc3bf20f8f9b1e90ea06146d34ef65e0c7cd4338..f793d3d8b54e5655e7127a598d9d52741a6a5ef4 100644
--- a/var/spack/repos/builtin/packages/pixman/package.py
+++ b/var/spack/repos/builtin/packages/pixman/package.py
@@ -42,7 +42,7 @@ def patch_config_h_for_intel(self):
         #
         if '%intel' in self.spec:
             filter_file(
-                '#define HAVE_GCC_VECTOR_EXTENSIONS /\*\*/',
+                r'#define HAVE_GCC_VECTOR_EXTENSIONS /\*\*/',
                 '/* #undef HAVE_GCC_VECTOR_EXTENSIONS */',
                 config_h
             )
diff --git a/var/spack/repos/builtin/packages/r-gtools/package.py b/var/spack/repos/builtin/packages/r-gtools/package.py
index 9fa653e4bf5e68ffdccfb28154b1966814577a35..2103df512f25c2b8e43b93b99dafb5ca718abba9 100644
--- a/var/spack/repos/builtin/packages/r-gtools/package.py
+++ b/var/spack/repos/builtin/packages/r-gtools/package.py
@@ -7,26 +7,38 @@
 
 
 class RGtools(RPackage):
-    """Functions to assist in R programming, including: - assist in developing,
-    updating, and maintaining R and R packages ('ask', 'checkRVersion',
-    'getDependencies', 'keywords', 'scat'), - calculate the logit and inverse
-    logit transformations ('logit', 'inv.logit'), - test if a value is missing,
-    empty or contains only NA and NULL values ('invalid'), - manipulate R's
-    .Last function ('addLast'), - define macros ('defmacro'), - detect odd and
-    even integers ('odd', 'even'), - convert strings containing non-ASCII
-    characters (like single quotes) to plain ASCII ('ASCIIfy'), - perform a
-    binary search ('binsearch'), - sort strings containing both numeric and
-    character components ('mixedsort'), - create a factor variable from the
-    quantiles of a continuous variable ('quantcut'), - enumerate permutations
-    and combinations ('combinations', 'permutation'), - calculate and convert
-    between fold-change and log-ratio ('foldchange', 'logratio2foldchange',
-    'foldchange2logratio'), - calculate probabilities and generate random
-    numbers from Dirichlet distributions ('rdirichlet', 'ddirichlet'), - apply
-    a function over adjacent subsets of a vector ('running'), - modify the
-    TCP\_NODELAY ('de-Nagle') flag for socket objects, - efficient 'rbind' of
-    data frames, even if the column names don't match ('smartbind'), - generate
-    significance stars from p-values ('stars.pval'), - convert characters
-    to/from ASCII codes."""
+    """Functions to assist in R programming.
+
+    Including:
+    - assist in developing, updating, and maintaining R and R packages
+      ('ask', 'checkRVersion', 'getDependencies', 'keywords', 'scat')
+    - calculate the logit and inverse logit transformations
+      ('logit', 'inv.logit')
+    - test if a value is missing, empty or contains only NA and NULL values
+      ('invalid')
+    - manipulate R's .Last function ('addLast')
+    - define macros ('defmacro')
+    - detect odd and even integers ('odd', 'even')
+    - convert strings containing non-ASCII characters (like single
+      quotes) to plain ASCII ('ASCIIfy')
+    - perform a binary search ('binsearch')
+    - sort strings containing both numeric and character components
+      ('mixedsort')
+    - create a factor variable from the quantiles of a continuous variable
+      ('quantcut')
+    - enumerate permutations and combinations ('combinations', 'permutation')
+    - calculate and convert between fold-change and log-ratio
+      ('foldchange', 'logratio2foldchange', 'foldchange2logratio')
+    - calculate probabilities and generate random numbers from Dirichlet
+      distributions ('rdirichlet', 'ddirichlet')
+    - apply a function over adjacent subsets of a vector ('running')
+    - modify the TCP_NODELAY ('de-Nagle') flag for socket objects
+    - efficient 'rbind' of data frames, even if the column names don't
+      match ('smartbind')
+    - generate significance stars from p-values ('stars.pval')
+    - convert characters to/from ASCII codes.
+
+    """
 
     homepage = "https://cran.r-project.org/package=gtools"
     url      = "https://cran.r-project.org/src/contrib/gtools_3.5.0.tar.gz"
diff --git a/var/spack/repos/builtin/packages/spark/package.py b/var/spack/repos/builtin/packages/spark/package.py
index e037c13f3e5cabd6c3511aaf90159e446d13e60f..9ca6a5aa26fff3453ec9c0637b819257e9f54705 100644
--- a/var/spack/repos/builtin/packages/spark/package.py
+++ b/var/spack/repos/builtin/packages/spark/package.py
@@ -54,6 +54,6 @@ def setup_environment(self, spack_env, run_env):
 
         # Remove whitespaces, as they can compromise syntax in
         # module files
-        hadoop_classpath = re.sub('[\s+]', '', hadoop_classpath)
+        hadoop_classpath = re.sub(r'[\s+]', '', hadoop_classpath)
 
         run_env.set('SPARK_DIST_CLASSPATH', hadoop_classpath)
diff --git a/var/spack/repos/builtin/packages/yorick/package.py b/var/spack/repos/builtin/packages/yorick/package.py
index 11d85e9d54879d209b58730c8f80b14be8648873..59cc2751cf92e8a77a1b816d38bf31260cdeab88 100644
--- a/var/spack/repos/builtin/packages/yorick/package.py
+++ b/var/spack/repos/builtin/packages/yorick/package.py
@@ -14,7 +14,7 @@ class Yorick(Package):
        files of numbers. Yorick includes an interactive graphics package, and a
        binary file package capable of translating to and from the raw numeric
        formats of all modern computers. Yorick is written in ANSI C and runs on
-       most operating systems (\*nix systems, MacOS X, Windows).
+       most operating systems (*nix systems, MacOS X, Windows).
     """
 
     homepage = "http://dhmunro.github.io/yorick-doc/"
diff --git a/var/spack/repos/builtin/packages/zfp/package.py b/var/spack/repos/builtin/packages/zfp/package.py
index efb6262ada8429304a3bd9a40d54b8b163864e74..5a69b030d7cdb1878f5c1a53e286741aa400847b 100644
--- a/var/spack/repos/builtin/packages/zfp/package.py
+++ b/var/spack/repos/builtin/packages/zfp/package.py
@@ -32,7 +32,7 @@ class Zfp(MakefilePackage):
     def edit(self, spec, prefix):
         config_file = FileFilter('Config')
         config_file.filter(
-            '^\s*#\s*DEFS\s*\+=\s*-DBIT_STREAM_WORD_TYPE\s*=\s*uint8',
+            r'^\s*#\s*DEFS\s*\+=\s*-DBIT_STREAM_WORD_TYPE\s*=\s*uint8',
             'DEFS += -DBIT_STREAM_WORD_TYPE=uint%s' %
             spec.variants['bsws'].value)