REreplace[NoCase](): string only? Or can a function be the replacement?
Hello, all,
According to Adobe documentation, REreplace() (ergo, REreplaceNoCase(), too) requires three arguments: the target string; the regex match; and the value to replace that match with. The docs also state that the third argument is a string. Nothing is mentioned of using a function for the third argument.
But in JavaScript (ex: str.replace(x,y)), while the prefix str is the target string, the two arguments that go inside the parenthesis are the regex or substring match, and the replacement - which can be either a string, or a function.
The reason I bring this to attention is because in the past I have needed (and now would like) to write something that will convert HTML entities into the character said entity is supposed to represent. But I have had no success by using just a string as the replacement.
For example: Say I have a string, such as "This is a test; this is only a test." (Yeah, I know, VERY basic.) Well, I don't always know that what I need to replace will be ;. It could be &#XXXX;, for all I know. But I do know that (at least most if not all the time) ; in CF is chr(59).
So I tried several variations of:
REreplaceNoCase( str, '&##(\d);', '#chr(\1)#', 'all' ) <!--- and more, but I'm kind of tired, so I'm only giving one example --->
None worked. Then (today) it occurred to me - a function might be able to do it. But the docs indicate that only a string can be the replacement for REreplace[NoCase]().
Frustrating.
Okay.. now I'm not sure where I'm going with this, coz it really isn't a question. But I guess that I'm wondering if Adobe has any plans to update REreplace() so that a function can be used as the replacement. Or, if anyone knows of an alternative.
V/r,
^_^
