JSFiddle - React, Tailwind, and code Playground
by Frank Liu
JavaScript
let file = "C:/folder/~mylog.doc";
alert('It is a temp file log ? ' + isTempFilelog(file));
function isTempFilelog(file)
{
if(Boolean(file))
{
var regex1 = /(\/~.*)/g; // match string that begins with /~
var regex2 = /(\/~.*\.tmp$)/gi; // match string begins with /~ and ends with .tmp 。 Case insensitive.
var regex3 = /(~.*\.tmp)/gi; // match string begins with ~ and ends with .tmp. Especially for Excel temp file。 Case insensitive.
var regex4 = /(\.tmp.ist$)/gi; // match string ends with .tmp.ist 。 Case insensitive.
var found1 = file.match(regex1);
var found2 = file.match(regex2);
var found3 = file.match(regex3);
var found4 = file.match(regex4);
if(found1 || found2 || found3 || found4 )
{
return true; // It is a temp file log.
} else {
return false; // It is real file log.
}
}
return false; // It is real file log.
}