You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/string/substring-before-last/README.md
+35
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,7 @@ Options:
121
121
-h, --help Print this message.
122
122
-V, --version Print the package version.
123
123
--search string Search string.
124
+
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
124
125
```
125
126
126
127
</section>
@@ -131,6 +132,20 @@ Options:
131
132
132
133
<sectionclass="notes">
133
134
135
+
### Notes
136
+
137
+
- If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
138
+
139
+
```bash
140
+
# Not escaped...
141
+
$ echo -n $'foo\nbar\nbaz'| substring-before-last --search a --split /\r?\n/
142
+
143
+
# Escaped...
144
+
$ echo -n $'foo\nbar\nbaz'| substring-before-last --search a --split /\\r?\\n/
145
+
```
146
+
147
+
- The implementation ignores trailing delimiters.
148
+
134
149
</section>
135
150
136
151
<!-- /.notes -->
@@ -146,6 +161,22 @@ $ substring-before-last abcdefg --search d
146
161
abc
147
162
```
148
163
164
+
To use as a [standard stream][standard-streams],
165
+
166
+
```bash
167
+
$ echo -n $'beep\nboop'| substring-before-last --search p
168
+
bee
169
+
boo
170
+
```
171
+
172
+
By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option.
173
+
174
+
```bash
175
+
$ echo -n 'beep\tboop'| substring-before-last --search p --split '\t'
t.strictEqual(stderr.toString(),'','does not print to `stderr`');
230
+
}
231
+
t.end();
232
+
}
233
+
});
234
+
189
235
tape('when used as a standard stream, if an error is encountered when reading from `stdin`, the command-line interface prints an error and sets a non-zero exit code',opts,functiontest(t){
0 commit comments