File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Rubberduck.RegexAssistant Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,20 @@ class Pattern
11
11
IRegularExpression RootExpression ;
12
12
MatcherFlags Flags ;
13
13
14
+ private readonly bool _hasStartAnchor ;
15
+ private readonly bool _hasEndAnchor ;
16
+
14
17
public Pattern ( string expression , bool ignoreCase , bool global )
15
18
{
16
19
Flags = ignoreCase ? MatcherFlags . IgnoreCase : 0 ;
17
20
Flags = global ? Flags | MatcherFlags . Global : Flags ;
18
21
19
- RootExpression = RegularExpression . Parse ( expression ) ;
22
+ _hasEndAnchor = expression [ expression . Length - 1 ] . Equals ( '$' ) ;
23
+ _hasStartAnchor = expression [ 0 ] . Equals ( '^' ) ;
24
+
25
+ int start = _hasStartAnchor ? 1 : 0 ;
26
+ int end = ( _hasEndAnchor ? 1 : 0 ) + start + 1 ;
27
+ RootExpression = RegularExpression . Parse ( expression . Substring ( start , expression . Length - end ) ) ;
20
28
}
21
29
22
30
}
You can’t perform that action at this time.
0 commit comments