Change numbers in a string to asterisks.

A little regular expression to change all numbers in a string to asterisks.

<cfset MyString = REReplace(MYString, [[:digit:]], *,ALL)>

Example:

<!--- Fill MyString with an example string --->
<cfset MyString="My credit card number is 1234 5678 9876 5432">
<cfset MyString = REReplace(MYString, [[:digit:]], *,ALL)>
<cfoutput>#MyString#</cfoutput>

My Credit card number is **** **** **** ****

 

Share this article!

Follow us!

Find more helpful articles: