diff options
author | amy <[email protected]> | 2023-02-28 13:59:52 +0000 |
---|---|---|
committer | amy <[email protected]> | 2023-02-28 13:59:52 +0000 |
commit | d39d0b7e02eee9773be2d6ac5f53fc86395a8197 (patch) | |
tree | a1d766aed4a0350af38f1d4804da402346c8a7ae /src/common.js | |
parent | 7abe9c7a3528782316b34328c8799c8e8f1933bb (diff) |
lots of things i think
Diffstat (limited to 'src/common.js')
-rw-r--r-- | src/common.js | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/src/common.js b/src/common.js index f7d2cca..3c8fcb4 100644 --- a/src/common.js +++ b/src/common.js @@ -11,4 +11,67 @@ function appendHtml(el, str) { } -const rem_emp = function (e) {return e !== "";};
\ No newline at end of file +const rem_emp = function (e) {return e !== "";}; + +function indexs_of(inp,sel){ + if(sel==''){ + let fm = [] + for(let n = 0; n<=inp.length;n++){ + fm.push(n) + } + //console.log(fm) + return fm + } + let m = [] + for(let i = inp.indexOf(sel);i>=0;i=inp.indexOf(sel,i+1)){ + m.push(i) + } + return m +} +function hrx(inp,match){ //hgx for human (readable) regex, a more user friendly regex + //similar to the ones used in command lines + for(let x in match){ + //console.log(match[x]) + if(match[0]=='*'){ + m = match.split("") + m.splice(0,1) + m = m.join("") + mm = m.split("*")[0] + //m = m.join("") + + if(!inp.includes(mm)) + return false + + //let zz = inp.indexOf(m) + let ava = indexs_of(inp,mm) + //console.log(m) + for(let a of ava){ + //console.log(a,m) + i = inp.split("") + i.splice(0,a) + i = i.join("") + let test = hrx(i,m) + if(test) + return true + + } + return false + //match = m + //console.log(m,i) + } else { + //console.log(inp,match) + if(inp[0]==match[0]){ + i = inp.split("") + ma = match.split("") + i.splice(0,1) + ma.splice(0,1) + inp=i.join("") + match=ma.join("") + } else { + return false + } + } + } + //console.log(inp,match) + return (inp==''&&''==match) +}
\ No newline at end of file |