JSFiddle - React, Tailwind, and code Playground

by dtracers

JavaScript

var simpleMatching = /(^(\s|<br>)*(\W|<br>)(\s|<br>)*$)|(^$)/;
var myMathching = /\w/;
var theirMatching = /^(?=.?\b\w\b)((?!<br>).)*$/;
    cases = ['<br>', // 0
             '   ', // 1
             '\n', // 2
             '\n', // 3
             '', // 4
            'word',// 5 true cases
             ' normal comment', // 6
             ' normal comment.', //7
             ' normal_comment ', //8
            'word<br>'];//9

console.log('---------------------------------');
for (var i=0; i<cases.length; i++)
{
    console.log(i, simpleMatching.test(cases[i]), myMathching.test(cases[i]), theirMatching.test(cases[i]));
}