Show HN: A more ergonomic sed using JavaScript regexes

Show HN: A more ergonomic sed using JavaScript regexes
1 point by ariabuckles 1 day ago | hide | past | web | favorite | discuss
I love `sed`, but specifying in-place replacement across linux/mac is challenging, and I find both the regular expression options hard to remember the exact syntax for.

So I built a small wrapper around String.prototype.replace to give the syntax and power of javascript regular expressions (and, optionally, javascript functions):

https://github.com/ariabuckles/jsed

Or to install:

    npm install -g @ariabuckles/jsed

Some examples:

You can use it pretty similarly to `sed`:

    echo "this is a test" | jsed 'w+' 'word:$&'
    > word:this word:is word:a word:test

Or you can use it more like javascript when needed:

     echo "1 2 3 4" | jsed '/d+/g' '(num) => num%2 == 0 ? "even" : "odd"'


Guidelines
| FAQ
| Support
| API
| Security
| Lists
| Bookmarklet
| Legal
| Apply to YC
| Contact

Read More