First of all, I know how most RegExp issues go away; and this is not one of the questions, please write my code.
My confusion is that my RegExp works with regexr and in chrome dev tools when polling document.body.textContent , but not in the HTML file after I read it in io.js.
io.js is version 1.5.1 running on windows 8
Why will it work in both of these places, but not in io.js? Don't I take into account what io.js does for reading files?
My RegExp should match " @{each ___->___} text and line breaks @{/each} " as in the link below, but instead it returns null
Here is what I am trying to use: http://regexr.com/3aldk
RegExp:
/@\{each ([a-zA-Z0-9->.]*)\}([\s\S]*)@\{\/each}/g
JS (example):
fs.readFile('view.html', {encoding:'utf8'}, function(error, html) { console.log(html.match(myRegExp));
HTML:
<!doctype html> <html> <head> <title>@{title}</title> </head> <body> <h1>@{foo.bar}</h1> <p> Lorem ipsum dolor sit amet, @{foo.baz.hoo} </p> @{each people->person} <div> <b>@{person.name}:</b> @{person.age} </div> @{/each} </body> </html>
Did I miss something obvious, like a character present on the back, but not once serving?
source share