Need to replace text in a JavaScript string? Use string.replace and you're done. Unless, of course, there are multiple instances to be replaced, since the string.replace() function only replaces the first occurrence.
I had that problem, and found Brandino's article, JavaScript String Replace All to be just the trick.
It seems that you can use a regular expression as the target of the string.replace function.
In fact, in addition to being able to do multiple replaces on a single target, this also would allow you to create a regex target for your replace that would replace different things with the same replacement text... which could be handy if you need to remove or replace certain unwanted characters throughout a string...
Monday, August 16, 2010
Friday, August 6, 2010
LEGO Mindstorms NXT sensors to limiting? Roll your own...
Found this neat how to article via HackADay.com...
Designing Lego Mindstorms NXT sensors - Stew’s Spot
...pretty neat... If only I could find some free time...
Designing Lego Mindstorms NXT sensors - Stew’s Spot
...pretty neat... If only I could find some free time...
Think:
electronics,
HackADay.com,
hacking,
hobbyist,
Internet,
LEGO,
Mindstorms,
problem solving,
Programming,
robots,
technology
Subscribe to:
Comments (Atom)