quote:
Originally posted by Mattike
Hmm... how do I let the script not parse "\%d" using a regular expression?
code:
cStr = cStr.replace(/%d/g, Math.floor(cSecs/86400));
How the hell can I tell it not to replace when it has a \ before it?! Never used negation in RegExps before...
I actually would not use regular expressions in this case:
1) it is not easy (not short) to include a not-matching character and yet not including it in the matching replace string
2) you will have troubles (wrong output) with subsequent replaces (think about the case where the string to replace with also includes tags like %d) (<= you already have this problem now, even without the added check for "\")
A solution to all this is doing as if you can't use regular expressions:
find the first occurance of
any tag, replace it if it doesn't begin with "\" and move on from that point forward in the string to find the next occurance of
any tag.
In that way you don't have problems when the tag "%dw" actually contains the text "%hw" and you do:
cStr = cStr.replace(/%dw/g, DayWord);
cStr = cStr.replace(/%hw/g, HourWord);
I know it is a bit far fetched (that people will use %hw inside the word text), but this is stuff to consider if you want to make a total fool proof plugin.
Another way, and still using regular expressions like you do, is to first replace stuff like "\%d" with something else and later replace it back (but this wont fix the errors you can get if word tags contain "%d" too). And you need to be uber carefull in what you're going to replace "\%d" with before you apply the regular expressions (I'd suggest to replace it with a non-printeable character with a low ascii value).
quote:
Originally posted by Mattike
quote:
Originally posted by CookieRevised
what text?
The text like "Only (!COUNTDOWN)...", shouldn't it be different for nickname and personal message?
you could make two different textboxes, yes. That's what I also did in the Holiday Counter Plugin, but it isn't essential; it is a nice feature though.