Page 1 of 1

First Character as uppercase character

Posted: Mon Jan 07, 2008 2:29 pm
by RAJEEV KATTA
Which function in transformer do I need to use to find whether the first character of a string is upper case or not.

Posted: Mon Jan 07, 2008 2:47 pm
by ray.wurlod
If

Use substring or Left() to isolate the first character.
Test this against itself with the UpCase() function applied, or against an upper case alphabet using the Index() function.
Use If to generate an int8 result.

Re: First Character as uppercase character

Posted: Mon Jan 07, 2008 9:06 pm
by JoshGeorge
Depends on your exact requirement.

Code: Select all

 If (Left(InputLink.InputColumn,1) > CHAR(64) and Left(InputLink.InputColumn,1) < CHAR(91)) then 'Y' else 'N'

Ex: "1test" will give you 'N'
Ex: "test" will give you 'N'
Ex: "Test" will give you 'Y'
or

Code: Select all

If (Left(InputLink.InputColumn,1) = UpCase(Left(InputLink.InputColumn,1)))  Then 'Y' else 'N'

Ex: "1test" will give you 'Y'
Ex: "test" will give you 'N'
Ex: "Test" will give you 'Y'

Posted: Mon Jan 07, 2008 11:48 pm
by ray.wurlod
Performance Tip
Putting the Left() function result into a stage variable would mean that you execute it once per row rather than twice per row. For squillions of rows this can make a noticeable difference.