diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index 33d0478997a22b2d723e242bebf6a8734a3a478e..3d5d4bd8f3be725df8286d64705634c5c83ed6a3 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -681,7 +681,7 @@ macro(DD4HEP_SETUP_ROOT_TARGETS)
   IF((TARGET ROOT::PyROOT OR TARGET ROOT::ROOTTPython) AND ${ROOT_VERSION} VERSION_GREATER_EQUAL 6.19)
     # some cmake versions don't include python patch level in PYTHON_VERSION
     IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0 AND CMAKE_VERSION VERSION_LESS_EQUAL 3.17.2)
-      string(REGEX MATCH [23]\.[0-9]+ REQUIRE_PYTHON_VERSION ${ROOT_PYTHON_VERSION})
+      string(REGEX MATCH [23]\\.[0-9]+ REQUIRE_PYTHON_VERSION ${ROOT_PYTHON_VERSION})
     ELSE()
       SET(REQUIRE_PYTHON_VERSION ${ROOT_PYTHON_VERSION})
     ENDIF()