-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (27 loc) · 837 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs');
const path = require('path');
const basedir = path.resolve(__dirname + '/');
const removeValue = (value, rule) => {
while(value.indexOf(rule) != -1)
value = value.replace(rule, '');
return value;
}
const customTrim = (value) => {
value = removeValue(value, '\t');
value = removeValue(value, '\n');
value = removeValue(value, '\r');
return value;
}
const bufferFile = (pathFile) => {
return fs.readFileSync(basedir + '\\' + pathFile);
}
const compiler = (pathFile) => {
const BUFFER = bufferFile(pathFile);
return BUFFER;
}
const simpleExample = '\\examples\\html-super\\simple.shtml';
const rawFile = customTrim(compiler(simpleExample).toString().trim());
const regexpTag = /main/;
console.log(rawFile);
const myRegExp = new RegExp(regexpTag, 'gm');
console.log(myRegExp.exec(rawFile));