diff --git a/anytree/resolver.py b/anytree/resolver.py
index <HASH>..<HASH> 100644
--- a/anytree/resolver.py
+++ b/anytree/resolver.py
@@ -219,7 +219,7 @@ class Resolver(object):
                 re_pat += "."
             else:
                 re_pat += re.escape(char)
-        return re_pat + r'\Z(?ms)'
+        return r'(?ms)' + re_pat + r'\Z'
 
 
 class ResolverError(RuntimeError):
Update resolver.py

Avoid to throw /my/path/resolver.py:<I>: DeprecationWarning: Flags not at the start of the expression 'expr\\Z(?ms)' in python <I>