File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 48614861 var global = false ; // True to replace all instances on a line, false to replace only 1.
48624862 if ( tokens . length ) {
48634863 regexPart = tokens [ 0 ] ;
4864+ if ( getOption ( 'pcre' ) && regexPart !== '' ) {
4865+ regexPart = new RegExp ( regexPart ) . source ; //normalize not escaped characters
4866+ }
48644867 replacePart = tokens [ 1 ] ;
48654868 if ( regexPart && regexPart [ regexPart . length - 1 ] === '$' ) {
48664869 regexPart = regexPart . slice ( 0 , regexPart . length - 1 ) + '\\n' ;
48994902 global = true ;
49004903 flagsPart . replace ( 'g' , '' ) ;
49014904 }
4902- regexPart = regexPart . replace ( / \/ / g, "\\/" ) + '/' + flagsPart ;
4905+ if ( getOption ( 'pcre' ) ) {
4906+ regexPart = regexPart + '/' + flagsPart ;
4907+ } else {
4908+ regexPart = regexPart . replace ( / \/ / g, "\\/" ) + '/' + flagsPart ;
4909+ }
49034910 }
49044911 }
49054912 if ( regexPart ) {
Original file line number Diff line number Diff line change @@ -3934,6 +3934,11 @@ testSubstitute('ex_substitute_or_word_regex', {
39343934 expectedValue : 'five|five \n three|four' ,
39353935 expr : '%s/(one|two)/five/g' ,
39363936 noPcreExpr : '%s/\\(one\\|two\\)/five/g' } ) ;
3937+ testSubstitute ( 'ex_substitute_forward_slash_regex' , {
3938+ value : 'forward slash \/ was here' ,
3939+ expectedValue : 'forward slash was here' ,
3940+ expr : '%s#\\/##g' ,
3941+ noPcreExpr : '%s#/##g' } ) ;
39373942testSubstitute ( 'ex_substitute_backslashslash_regex' , {
39383943 value : 'one\\two \n three\\four' ,
39393944 expectedValue : 'one,two \n three,four' ,
You can’t perform that action at this time.
0 commit comments