@utilx/string

```typescript npm install -D @utilx/string ```

Usage no npm install needed!

<script type="module">
  import utilxString from 'https://cdn.skypack.dev/@utilx/string';
</script>

README

string-utils

npm install -D @utilx/string

strmod

const { IP } = Pattern.regex
const s = "    ip: 127.0.0.1 1.1.1.1 "
const expect_string = strmod(s).trySkip(IP).replace(IP, "127.0.0.1").dumps()

LineEditor

const fp = "tsconfig.json"
LineEditor.fromFile$(fp)
    .locate(/"target"/).replace(true, false)

const fp = "tsconfig.json"
LineEditor.fromFile$(fp)
    .locate(/"target"/).strmod().trySkip()

r

We provide a magic letter r to provide:

  1. embeded regex patterns
  2. r.or
  3. r

For example, if we want to identify the postcode

r( r(r.INT0_255, ".").l(3), r.INT0_255 )

identify the pairname:

p1: 90, p2: 12, p3: 12
const regex = r(r.name("\w", "name"), /:/, r.name(/\d+/, "score"))
for (let i of regex.visit("p1: 90, p2: 12, p3: 12")){
    console.log(i.group!.name, i.group!.score)
}