Jump to content

ReplaceSubstring search ignoring case?


Recommended Posts

Hello all, I've been using a script to replace registered names in their proper cases with a registered mark.


s = ReplaceSubstring(s, "Biospot", "<span>" + "bioSpot" + "<f name=\"Arial\">" + "<p br=false superoffset=188 superratio=25><superscript>® </superscript>" + "</span>");


Is there a way to search/replace any text that is "biospot" regardless of its case? I've noticed the data I receive is not consistent, i.e. "biospot", "BIOSPOT", "BIOspot". The correct text should always be "bioSpot"


thanks for any help!

Link to comment
Share on other sites

s = s.replace(/biospot/ig, "<span>bioSpot<f name=\"Arial\"><p br=false superoffset=188 superratio=25><superscript>® </superscript></span>");

the replace() method will search for the string between the forward slashes and replace it with what is in quotes. The "i" after the forward slashes indicates the search term is case insensitive while the "g" indicates that the find & replace should occur as many times as necessary in the original string.

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.

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