I have a list of Student ID's along with the results, three test results, each student recieved. I have created a fileReader to read text from a local document and stored the results in a variable. I have a regex for pulling the information I need, which should work but returns null.
The information is stored as;
C00695260
93
76
86
The regex im trying to use is,
/C\d{8}\s\d{2}\d?\s\d{2}\d?\s\d{2}\d?/g
which highlights what I want in sublime but not in the program, or browser console. It works as expected until after,
/C\d{8}\s\d{2}\d?\s/g
,
but I can't work out why. This is my first post so sorry if I'm doing anything wrong;
This dosn't work
var textIn;
var r =/B\d{8}\s\d{2}\d?\s\d{2}\d?\s\d{2}\d?/g;
var print;
//crete a function the read listen fot the file to change
document.getElementById('openFile').addEventListener('change', function(){
var reader = new FileReader();
reader.onload = function(){
textIn = this.result;
print = textIn.match(r);
document.getElementById('Filecontents').textContent = print;
}
reader.readAsText(this.files[0]);
})
This works!
var textIn;
var r =/(B\d{8})\s/g;
var print;
//crete a function the read listen fot the file to change
document.getElementById('openFile').addEventListener('change', function(){
var reader = new FileReader();
reader.onload = function(){
textIn = this.result;
print = textIn.match(r);
document.getElementById('Filecontents').textContent = print;
}
reader.readAsText(this.files[0]);
})