mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
Update sed documentation regarding capture groups (#558)
* Update sed documentation regarding capture groups * Remove unix sed example for brevity * Regen README
This commit is contained in:
parent
4a1bce8815
commit
12c103fc43
@ -393,6 +393,15 @@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
|
||||
Reads an input string from `files` and performs a JavaScript `replace()` on the input
|
||||
using the given search regex and replacement string or function. Returns the new string after replacement.
|
||||
|
||||
Note:
|
||||
|
||||
Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
|
||||
using the `$n` syntax:
|
||||
|
||||
```javascript
|
||||
sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
|
||||
```
|
||||
|
||||
|
||||
### sort([options,] file [, file ...])
|
||||
### sort([options,] file_array)
|
||||
|
||||
@ -25,6 +25,15 @@ common.register('sed', _sed, {
|
||||
//@
|
||||
//@ Reads an input string from `files` and performs a JavaScript `replace()` on the input
|
||||
//@ using the given search regex and replacement string or function. Returns the new string after replacement.
|
||||
//@
|
||||
//@ Note:
|
||||
//@
|
||||
//@ Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified
|
||||
//@ using the `$n` syntax:
|
||||
//@
|
||||
//@ ```javascript
|
||||
//@ sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt');
|
||||
//@ ```
|
||||
function _sed(options, regex, replacement, files) {
|
||||
// Check if this is coming from a pipe
|
||||
var pipe = common.readFromPipe();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user