I m currently trying to parse a smil (xml) file.
The biggest issue I have is if the line do not contain anything else but whitespace and end of line.
I have trying:
if(line.trim()==='\n')
if(line.trim().length<='\n'.length)
n='\n';
if(line.trim()===n)
None of them worked. Is there a way to check if there s no 'real' character in a string? Or if the string contain only \t, \n and whitespace?
read some tutorial on regex and then try this
if (/^\s*$/.test(line)) console.log('line is blank');
/^\s*$/
is a regex that means
^ anchor begin of string
\s whitespace character class (space, tab, newline)
* zero or more times
$ end of string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With