simoncpage Posted October 13, 2004 Posted October 13, 2004 Does anyone have a calculation that will conver double barrel surnames to proper case - for example Smith-Davis (not Smith-davis) also O'Neill not O'neill.....there maybe others but has anyone got a solution that handles all these? Thanks
Lee Smith Posted October 13, 2004 Posted October 13, 2004 If(Left(LeftWords(Text,1),2)="O'", "O'" & If(PatternCount(LeftWords(Text,1),"-") =1, Proper(Middle(Text,3,Position(Text,"-",1,1)-2)) & Proper(Right(LeftWords(Text,1),Length(LeftWords(Text,1)) - Position(Text, "-",1,1))), Proper(Middle(Text,3,Length(LeftWords(Text,1))-2))), If(Left(LeftWords(Text,1),2)="D'","D'" & If(PatternCount(LeftWords(Text,1),"-") >=1, Proper(Middle(Text,3,Position(Text,"-",1,1)-2)) & Proper(Right(LeftWords(Text,1),Length(LeftWords(Text,1)) - Position(Text, "-",1,1))), Proper(Middle(Text,3,Length(LeftWords(Text,1))-2))), If(Left(LeftWords(Text,1),2)="Mc","Mc" & If(PatternCount(LeftWords(Text,1),"-") =1, Proper(Middle(Text,3,Position(Text,"-",1,1)-2)) & Proper(Right(LeftWords(Text,1),Length(LeftWords(Text,1)) - Position(Text, "-",1,1))), Proper(Middle(Text,3,Length(LeftWords(Text,1))-2))), If(PatternCount(LeftWords(Text,1),"-") =1, Proper(Left(Text,Position(Text,"-",1,1))) & Proper(Right(LeftWords(Text,1),Length(LeftWords(Text,1)) - Position(Text, "-",1,1))), Proper(LeftWords(Text,1)))))) HTH Lee
QuinTech Posted October 13, 2004 Posted October 13, 2004 Middle ( "isdnklWOW!!!nmklcasdnfc" , 7 , 6 )
transpower Posted October 13, 2004 Posted October 13, 2004 Try: If (PatternCount (Test_Name;"-") = 0 ; Test_Name ; ( Let ( [ pos = Position(Test_Name ; "-" ; 1 ; 1) + 1; letter = Middle(Test_Name;pos;1)] ; Replace (Test_Name; pos;1;TextStyleAdd(letter;Uppercase))))) Probably Queue could come up with something simpler, but at least the above works.
transpower Posted October 13, 2004 Posted October 13, 2004 Here is another method: If (PatternCount(Test_Name ; "-" ) = 0 ; Test_Name ; Let ( [ pos = Position(Test_Name ; "-" ; 1 ; 1 ) + 1 ; letter = Middle (Test_Name; pos;1)] ; Replace (Test_Name ; pos ; 1 ; Upper(letter)))) Versions before 7 don't have the Let function, so in that situation just substitute the full strings for pos and letter.
Recommended Posts
This topic is 7415 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now