https://github.com/alxpez/parsist
text parser, cleaner and formatter
https://github.com/alxpez/parsist
array cleaner formatter list parser raw regexp string
Last synced: 5 months ago
JSON representation
text parser, cleaner and formatter
- Host: GitHub
- URL: https://github.com/alxpez/parsist
- Owner: alxpez
- Created: 2018-07-22T14:27:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-29T15:18:23.000Z (almost 8 years ago)
- Last Synced: 2025-11-06T02:16:41.704Z (8 months ago)
- Topics: array, cleaner, formatter, list, parser, raw, regexp, string
- Language: JavaScript
- Homepage: https://npmjs.com/package/parsist
- Size: 48.8 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# parsist
> Raw text parser, cleaner and formatter
## Install
```bash
npm i -s parsist
```
## Docs
```js
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
```js
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
```bash
sample
raw
text
to
parse
```
```bash
sample, raw, text, to, parse
```
> Check _parsist/sample/index.js_ for specific use cases