JSFiddle - React, Tailwind, and code Playground

by tylermwashburn

HTML

<p id="output">The match was found on line </p>

JavaScript

var string = "This\nstring\nhas\nmultiple\nlines.",
    astring = string.split('\n'),
    match = /has/;

Array.each(astring, function (line, number) {
    if (match.exec(line))
        $('output').innerHTML += number + 1;
});