Using REXX I need to make all the first letter CAPS, of a word in a sentence to be caps. For example, if input is:
Code: Select all
this is example.
Code: Select all
This is example.
Moderator: mickeydusaor
Code: Select all
this is example.
Code: Select all
This is example.
Code: Select all
/*REXX*/
INPUT='this is a string'
LengthofString = LENGTH(INPUT)
OUTPUT=TRANSLATE(SUBSTR(INPUT,1,1))||SUBSTR(INPUT,2,LENGTHOFSTRING-1)
SAY ' output = ' output
Code: Select all
this is example.
Code: Select all
This Is Example.
Code: Select all
/*REXX*/
Input='this is a string'
X = WORDS(Input)
Output = ''
Do I = 1 to X
Out.I = Subword(Input,I,1)
Lengthofstring = Length(Out.I)
Out.I=Translate(Substr(Out.I,1,1))||Substr(Out.I,2,Lengthofstring-1)
If I = 1 Then Do
Output = Out.I
End
Else Do
Output = Output || ' ' ||Out.I
End
end
SAY ' Input = ' Input
SAY ' Output = ' Output
Code: Select all
Input = this is a string
Output = This Is A String
Code: Select all
This is eXAMple
Code: Select all
This is EXAMple
Code: Select all
This is Example
Yes, sorry for the changing description. I did not realize it until I kept on working with data.Pandora-Box wrote:Are you trying to convert the first character to UPPER and rest all to lower irrespective of the input?
Code: Select all
/*REXX*/
Input= 'This is eXAMple'
A2ZU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
A2ZL = 'abcdefghijklmnopqrstuvwxyz'
X = WORDS(Input)
Output = ''
Do I = 1 to X
Out.I = Subword(Input,I,1)
Lengthofstring = Length(Out.I)
Out.I=Translate(Substr(Out.I,1,1))||,
Translate(Substr(Out.I,2,Lengthofstring-1),A2ZL,A2ZU)
If I = 1 Then Do
Output = Out.I
End
Else Do
Output = Output || ' ' ||Out.I
End
End
Code: Select all
Input = This is eXAMple
Output = This Is Example
You need to be a member in order to post a reply
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute