Jump to content

Recommended Posts

Posted

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

Posted

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.

  • 5 years later...
Posted

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. 

Posted

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)", "&trade;");

 

  • Like 1

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...