Skip to content

Commit 00e1824

Browse files
revise R.bound
1 parent 30bdb2a commit 00e1824

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

scriptum.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6323,6 +6323,9 @@ R.normalize = s => s
63236323
.replaceAll(/<nl\/>/g, "\n");
63246324

63256325

6326+
R.concat = rx => ry => R(rx.source + ry.source, rx.flag + ry.flags);
6327+
6328+
63266329
//█████ Common Patterns ███████████████████████████████████████████████████████
63276330

63286331

@@ -7179,28 +7182,22 @@ R.sliceTo = search => s => {
71797182
/* Create a more general bound than `\b` by combining additional character
71807183
classes like `[x-z]` or "\w" or even "ß" in a disjunctive manner. */
71817184

7182-
R.bound = flags => (...classes) => {
7183-
const bound = "(?<=\\b|" + classes.join("|") + ")";
7185+
R.preBound = flags => (...classes) => {
7186+
const bound = "(?<=^|" + classes.join("|") + ")";
71847187
return R(bound, flags);
71857188
};
71867189

71877190

7188-
// prepend a bound on the left side of a regular expression
7189-
7190-
R.prependBound = bound => rx =>
7191-
R(bound.source + rx.source, bound.flags + rx.flags);
7192-
7193-
7194-
// append a bound on the right side of a regular expression
7195-
7196-
R.appendBound = bound => rx =>
7197-
R(rx.source + bound.source, bound.flags + rx.flags);
7198-
7191+
R.sufBound = flags => (...classes) => {
7192+
const bound = "(?=$|" + classes.join("|") + ")";
7193+
return R(bound, flags);
7194+
};
71997195

7200-
// append/prepend a bound on both sides of a regular expression
72017196

7202-
R.concatBound = bound => rx =>
7203-
R(bound.source + rx.source + bound.source, bound.flags + rx.flags);
7197+
R.inBound = flags => (...classes) => {
7198+
const bound = "(?:" + classes.join("|") + ")";
7199+
return R(bound, flags);
7200+
};
72047201

72057202

72067203
//█████ Generalizing ██████████████████████████████████████████████████████████

0 commit comments

Comments
 (0)