@typeshell/string-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

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:

  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)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @typeshell/string-utils

Weekly Downloads

0

Version

0.0.5

License

ISC

Unpacked Size

57.3 kB

Total Files

50

Last publish

Collaborators

  • amslime
  • x-cmd
  • edwinjhlee
  • lteam