I'm replacing text with font icons. An look up table would look like:-
var sym = {'(a)': (apple icon in utf-8),
'(A)': (angel icon),
...
'(g)': (...),
'(G)': (last icon) } anything after G is ignored.
Now (a)iPhone when translated to upper case should be (a)IPHONE, leaving the (a) untouched since uppercase (A) is a different icon altogether. Anything that doesn't match like (r)iPhone or (tm)iPhone would be converted.
Question: Is there an algorithm that avoids character by character checking, perhaps using native regex functions? Enclosed is the Javascript coding:
'(a) (az)text'.replace(/\(\w+\)/g, function (matches) {
return matches } )
.replace(/.*(?!\(\w+\)).*/g, function (matches) { // needs fixing
return matches.toUpperCase() }
) // returns "(A) (AZ)text"