parsist
v1.0.6
Published
Raw text parser, cleaner and formatter
Downloads
20
Maintainers
Readme
parsist
Raw text parser, cleaner and formatter
Install
npm i -s parsist
Docs
function parser(
raw: string,
delimiters: string | string[],
toString: boolean,
separator: string
): string | string[]
Parse and clean a string of raw items based on the given regex-character delimiters
@param raw — Raw text/paragraph to parse and clean
@param delimiters — Delimiters must be valid regex characters
@param toString — Whether to get the result as a string or not (return an array of strings)
@param separator — Used as the item separator when returning a string
Use
import { parser } from 'parsist'
let raw = `
sample ,
, raw .
text * to
parse
`
let delimiter = '[\\.\\,\\n\\*\\t]'
// Example 1
console.log(
parser(raw, delimiter, true, '\n')
)
// Example 2
console.log(
parser(raw, delimiter, true, ', ')
)
Outputs
sample
raw
text
to
parse
sample, raw, text, to, parse
Check parsist/sample/index.js for specific use cases