String case: Difference between revisions

Content added Content deleted
(Changed task description, modified all code examples to suit.)
Line 1: Line 1:
{{task}}
{{task}}

Demonstrates how to convert a string to UPPER CASE.
Take the string "alphaBETA", and demonstrate how to convert it to UPPER-CASE and lower-case.


==[[Ada]]==
==[[Ada]]==
Line 18: Line 19:
[[Category:Forth]]
[[Category:Forth]]


create s ," abc123"
create s ,"alphaBETA"
s count type \ shows: abc123
s count type \ shows: alphaBETA
s count 2dup upper type \ shows: ABC123
s count 2dup upper type \ shows: ALPHABETA
s count 2dup lower type \ shows: abc123
s count 2dup lower type \ shows: alphabeta


==[[JavaScript]]==
==[[JavaScript]]==
[[Category:JavaScript]]
[[Category:JavaScript]]


alert( "lower case text".toUpperCase() );
alert( "alphaBETA".toUpperCase() );
alert( "alphaBETA".toLowerCase() );


Output:
Output:
ALPHABETA
LOWER CASE TEXT
alphabeta


==[[Perl]]==
==[[Perl]]==
Line 35: Line 38:
'''Interpreter:''' [[Perl]] v5.x
'''Interpreter:''' [[Perl]] v5.x


my $string = uc('string to uppercase');
my $string = "alphaBETA";
my $uppercase = uc($string);
my $lowercase = lc($string);



==[[Python]]==
==[[Python]]==
Line 41: Line 47:


s = "alphaBETA"
s = "alphaBETA"
print s.upper() #or s.lower()
print s.upper()
print s.lower()


==[[SQL]]==
==[[SQL]]==