Plugin samples
Working with regular expressions
This plugin replaces uppercase HTML tags with lowercase tags in selected text.
function StrLowercaseTags(s) {
var matches;
var poses;
var f;
var tagpart;
var tagpos = 0;
if (RegexMatchAll(s, "<\/?([A-Z]+)[^<>]*>", False, matches, poses)) {
if (Length(matches) > 0) {
for (f = 0; f < Length(matches); f++) { //iterate through all matches
tagpart = _v(matches, [f, 1]);
tagpos = _v(poses, [f, 1]);
DeleteStr(s, tagpos, Length(tagpart));
Insert(Lowercase(tagpart), s, tagpos);
}
}
}
return s;
}
function LowercaseTags(Sender) {
var s = StrLowercaseTags(Editor.SelText);
Editor.SelText = s;
}
Script.RegisterDocumentAction("", "Lowercase tags", "", &LowercaseTags);
Notes
Notice that to access multidimensional arrays containing matching results, function _v is used.