@typeshell/string-utils
v0.0.5
Published
```typescript npm install -D @utilx/string ```
Downloads
1
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").dump()
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:
- embeded regex patterns
- r.or
- 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)
}