Jump to content

Hyphenated Name Rule???


TroyM68

Recommended Posts

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 by TroyM68
Link to comment
Share on other sites

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