TroyM68 Posted June 28, 2016 Share Posted June 28, 2016 (edited) Hello all, I am trying to create a rule that will do two things if possible. This is really an email rule. I would like to format the email address to capitalize the first letter of both the first and last name... second, I would like the rule to search for a specific character in the email field, for example a hyphen (-), and then capitalize the first letter after the hyphen. I thought this would have been discussed, but I haven't been able to find a thread mentioning this. Please let me know if this is possible. Example: AnY.character-CAP@help.com to: Any.Character-Cap@help.com Thank you! Edited April 20, 2017 by TroyM68 Quote Link to comment Share on other sites More sharing options...
tou Posted June 28, 2016 Share Posted June 28, 2016 (edited) I came up with a code: // Build a string of the letters A through Z s = "my.name-cms@google-analytics.com" var a = "" var b = Len(s) var passedAtSign = 0 var printUpperChr = 0 for (c = 0; c < b; c++) { // checks to see if we are passed our @ sign if (Mid(s, c+1 ,1)=="@") passedAtSign = 1 // Upper case 1st character of email if (c==0) a = a + ToUpper(Mid(s, c+1 ,1)) else { // if after 1st pass it's a period or dash, // toggle printUpperChr should be set to 1 // and if not passed the @ sign, passedAtSign // should still be 0 at this point if (printUpperChr == 1 && passedAtSign==0) a = a + ToUpper(Mid(s, c+1 ,1)) else a = a + ToLower(Mid(s, c+1 ,1)) //flags to print next character upper if (Mid(s, c+1 ,1)=="." || Mid(s, c+1 ,1)=="-") printUpperChr = 1 else printUpperChr = 0 } } return a; and came up with the results of: My.Name-Cms@google-analytics.com Hopes this helps.... Edited June 28, 2016 by tou Quote Link to comment Share on other sites More sharing options...
TroyM68 Posted June 28, 2016 Author Share Posted June 28, 2016 Tou, This worked perfectly, Thank you! Quote Link to comment Share on other sites More sharing options...
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.