Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 28th, 2016, 08:07 AM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Default Hyphenated Name Rule???

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!

Last edited by TroyM68; April 19th, 2017 at 07:06 PM..
Reply With Quote
  #2  
Old June 28th, 2016, 01:22 PM
tou tou is offline
Regular Contributor
 
Join Date: Oct 2015
Posts: 107
Default Re: Hyphenated Name Rule???

I came up with a code:
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....

Last edited by tou; June 28th, 2016 at 01:28 PM..
Reply With Quote
  #3  
Old June 28th, 2016, 03:52 PM
TroyM68 TroyM68 is offline
Junior Community Member
 
Join Date: Mar 2016
Location: Tampa, FL
Posts: 31
Default Re: Hyphenated Name Rule???

Tou,
This worked perfectly, Thank you!
Reply With Quote
Reply

Tags
email, hyphenated-name

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:21 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.