@@ -472,20 +472,27 @@ abstract class RegexString extends StringLiteral {
472
472
)
473
473
}
474
474
475
- private predicate flagGroupStart ( int start , int end , string c ) {
475
+ private predicate flagGroupStart ( int start , int end ) {
476
476
this .isGroupStart ( start ) and
477
477
this .getChar ( start + 1 ) = "?" and
478
- end = start + 3 and
479
- c = this .getChar ( start + 2 ) and
480
- c in [ "i" , "m" , "s" , "u" , "x" , "U" ]
478
+ this .getChar ( start + 2 ) in [ "i" , "m" , "s" , "u" , "x" , "U" ] and
479
+ end = start + 2
480
+ }
481
+
482
+ private predicate flagGroup ( int start , int end , string c ) {
483
+ exists ( int inStart , int inEnd |
484
+ this .flagGroupStart ( start , inStart ) and
485
+ this .groupContents ( start , end , inStart , inEnd ) and
486
+ this .getChar ( [ inStart .. inEnd - 1 ] ) = c
487
+ )
481
488
}
482
489
483
490
/**
484
491
* Gets the mode of this regular expression string if
485
492
* it is defined by a prefix.
486
493
*/
487
494
string getModeFromPrefix ( ) {
488
- exists ( string c | this .flagGroupStart ( _, _, c ) |
495
+ exists ( string c | this .flagGroup ( _, _, c ) |
489
496
c = "i" and result = "IGNORECASE"
490
497
or
491
498
c = "m" and result = "MULTILINE"
@@ -540,7 +547,7 @@ abstract class RegexString extends StringLiteral {
540
547
private predicate groupStart ( int start , int end ) {
541
548
this .nonCapturingGroupStart ( start , end )
542
549
or
543
- this .flagGroupStart ( start , end , _ )
550
+ this .flagGroupStart ( start , end )
544
551
or
545
552
this .namedGroupStart ( start , end )
546
553
or
0 commit comments