@@ -7176,30 +7176,31 @@ R.sliceTo = search => s => {
71767176//█████ Word Boundaries ███████████████████████████████████████████████████████
71777177
71787178
7179- /* Create a more general word boundary pattern (`\b`) by combining the passed
7180- subpattern with its left/right character classes and create a regular expression
7181- from it. */
7179+ /* Create a more general bound than `\b` by combining additional character
7180+ classes like `[x-z]` or "\w" or even "ß" in a disjunctive manner. */
71827181
7183- R . bound = ( { left , right } ) => rx => {
7184- const flags = left . flags + right . flags + rx . flags ;
7185- return R ( `(?<=^|[ ${ left } ]) ${ rx . source } (?=$|[ ${ right } ])` , flags ) ;
7182+ R . bound = flags => ( ... classes ) => {
7183+ const bound = "(?<=\\b|" + classes . join ( "|" ) + ")" ;
7184+ return R ( bound , flags ) ;
71867185} ;
71877186
71887187
7189- // create only a left boundary
7188+ // prepend a bound on the left side of a regular expression
71907189
7191- R . leftBound = left => rx => {
7192- const flags = left . flags + rx . flags ;
7193- return R ( `(?<=^|[${ left } ])${ rx . source } ` , flags ) ;
7194- } ;
7190+ R . prependBound = bound => rx =>
7191+ R ( bound . source + rx . source , bound . flags + rx . flags ) ;
71957192
71967193
7197- // create only a right boundary
7194+ // append a bound on the right side of a regular expression
71987195
7199- R . rightBound = right => rx => {
7200- const flags = right . flags + rx . flags ;
7201- return R ( `${ rx . source } (?=$|[${ right } ])` , flags ) ;
7202- } ;
7196+ R . appendBound = bound => rx =>
7197+ R ( rx . source + bound . source , bound . flags + rx . flags ) ;
7198+
7199+
7200+ // append/prepend a bound on both sides of a regular expression
7201+
7202+ R . concatBound = bound => rx =>
7203+ R ( bound . source + rx . source + bound . source , bound . flags + rx . flags ) ;
72037204
72047205
72057206//█████ Generalizing ██████████████████████████████████████████████████████████
0 commit comments