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-after/README.md
+35
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,7 @@ Options:
134
134
-V, --version Print the package version.
135
135
--search string Search string.
136
136
--from-index int Start index. Default: 0.
137
+
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
137
138
```
138
139
139
140
</section>
@@ -144,6 +145,20 @@ Options:
144
145
145
146
<sectionclass="notes">
146
147
148
+
### Notes
149
+
150
+
- If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
151
+
152
+
```bash
153
+
# Not escaped...
154
+
$ echo -n $'foo\nbar\nbaz'| substring-after --search a --split /\r?\n/
155
+
156
+
# Escaped...
157
+
$ echo -n $'foo\nbar\nbaz'| substring-after --search a --split /\\r?\\n/
158
+
```
159
+
160
+
- The implementation ignores trailing delimiters.
161
+
147
162
</section>
148
163
149
164
<!-- /.notes -->
@@ -159,6 +174,22 @@ $ substring-after abcdefg --search d
159
174
efg
160
175
```
161
176
177
+
To use as a [standard stream][standard-streams],
178
+
179
+
```bash
180
+
$ echo -n $'bar\nbaz'| substring-after --search b
181
+
ar
182
+
az
183
+
```
184
+
185
+
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.
186
+
187
+
```bash
188
+
$ echo -n 'bar\tbaz'| substring-after --search b --split '\t'
t.strictEqual(stderr.toString(),'','does not print to `stderr`');
277
+
}
278
+
t.end();
279
+
}
280
+
});
281
+
234
282
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