traba5058 Posted November 29, 2017 Posted November 29, 2017 Good Morning! I have a javascript rule to replace the above characters & superscript them. var s = Field("Name"); return s.replace(/(™|®|©)/g,'<superscript>$1</superscript>'); It is not working. Will you let me know how the marks should be entered in the database? Thanks, Traba Quote
Dan Korn Posted November 29, 2017 Posted November 29, 2017 Please be more specific than "It is not working." What does your data look like? If it already has the symbols in it, then you can look for those directly: return Field("Name").replace(/(™|®|©)/g,'<superscript>$1</superscript>'); Though the trademark symbol is usually already superscripted in most fonts, so really just this: return Field("Name").replace(/(®|©)/g,'<superscript>$1</superscript>'); If it's a job that will be run in MarcomCentral or a similar system, where it may use flat-file (delimited) text data for local compositions but tagged markup data for online compositions, you can do this: return TaggedDataField("Name").replace(/(®|©)/g,'<superscript>$1</superscript>'); Make sure to check the "Treat returned strings as tagged text" box. Quote
psmosser Posted November 3, 2023 Posted November 3, 2023 Have a similar issue that I need a little help on. Data is " CFP®, ChFC®, CPWA®, CEPA®, AAMS(TM)" I need to replace the "(TM)" with just a superscript "TM". return Field("Designation").replace,(/(TM)/g,'<superscript>TM</superscript>'); This returns the TM in superscript but the ( ) remain. How do I get rid of those? Thanks in advance. Quote
ThomasLewis Posted November 3, 2023 Posted November 3, 2023 You're using a regular expression to do the replacement there in your script. The () aren't treated as literal characters in case, they split up segments into groups. You can escape them so they are treated as characters like this: return Field("Designation").replace(/\(TM\)/g,'<superscript>TM</superscript>'); But a better solution would be to just use a simple string replacement: return Field("Designation").replace("(TM)",'<superscript>TM</superscript>'); Or better yet use the actual TM entity: return Field("Designation").replace("(TM)", "™"); 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.