In comp.lang.javascript message <0f8eb53f-534e-49f1-90c4-2ab9e7f9e26a@2g
2000hsn.googlegroups.com>, Thu, 5 Jun 2008 15:09:23, Yin99
<ws@ziowave.composted:
>I have some innerHTML stored as a string, and I would like to know how
many time throughout the whole innerHTML the occurence of "Hello<BR>"
occurs. I was wondering if RegEx or some elequant method exists?
One way is to use D.replace(/Hello<BR>/g) and see how much shorter
that is.
Another : S.match(/(Hello<BR>)/g).length - if the string varies,
use new RegExp rather than a literal.
If using .split("Hello<BR>") you may need to be concerned about the
possibility of it being first or last, and which browser is in use.
See also in <URL:http://www.merlyn.demon.co.uk/js-valid.htm#SSRA>.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.