diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index b6b1be9244255dea7090d0068afe61870bde4a28..26d77a2abb3c026fef0c9e4ea31bed8b5f689fc4 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -63,11 +63,13 @@ QByteArray QEglFSHooks::fbDeviceName() const
 int QEglFSHooks::framebufferIndex() const
 {
     int fbIndex = 0;
+#ifndef QT_NO_REGULAREXPRESSION
     QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
     QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName());
     if (match.hasMatch())
         fbIndex = match.captured(1).toInt();
 
+#endif
     return fbIndex;
 }