Jump to content

Changing Case & Superscript in 1 Field


Recommended Posts

I'm working on a business card that has 1 street address field. I need to change the case to uppercase & superscript the street name when it is a number.

 

Ex: North 44th Street should change to NORTH 44TH STREET and the th in 44th needs to superscript.

 

Is there a way to do this with javascript or is my only option to create formatted text resources?

Link to comment
Share on other sites

Use the "ToUpper" function to convert the address to uppercase. Then use a regex similar the the one below to replace any digit followed by "ST", "TH", "RD", or "ND" with the matched digit and the superscripted matched letters.

return ToUpper(Field('Street')).replace(/(\d)(ST|TH|RD|ND)/g, '$1<superscript>$2</superscript>');

Link to comment
Share on other sites

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...