Poliparser
Poliparse is used to extract and parse data from strings, files, urls and many other objects in a simple and fast way.
The Default modules allows you to parse:
- String
- Array
- Object
- DOM Elements
- JSON
- CSV
- Hash & Chipertext
You can use the default modules or easily add your custom one ( see all the modules on the Examples page ).
Install
npm install --save poliparser
Usage
Import and Instantiate Poliparser
const Poliparser = ; let p = ;
set a parser template,
In this example is used the module between
from str
library.
p;
let data = `<title>hello</title> <div class=".container"> <a href="link1.html">link1</a> </div>`; let output = p; console;
output
hello
ps. The fastest way is to pass it in the declaration like this
let p = m: 'between' from: '<title>' to: '</title>';
Documentation
See Here for complete modules documentation and Here for real world examples.
Add Module
You can use setModule()
and requireModule()
to add custom modules.
let p = ; p; p; let out = p; console;
same as
let p = ; p; p; let out = p; console;
//myModule.jsmodule { return data;};
output
3 6 9
Add Library
You can add a new library with the setLibrary or requireLibrary method.
let p = ; p; p; let out = p; console;
same as
let p = ; p; p
//myLib.jsmoduleexports = { return data * blockvalue; } { return data + blockvalue; }
output
32