Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tolower + toupper 1

Status
Not open for further replies.

michciub

Programmer
Nov 21, 2007
4
PL
How write a script which will change the lower letter to big letter and big letter to lower letter ?
 
I'd suggest by start reading the awk manual.
I might be way off on the matter though....

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Is this possible to do it without function, or it's only one way to solve this problem??? (just use regular expression)


function switchcase(s , n, a, rv, i, c) {

n = split(s, a, //)
rv = ""

for (i = 1; i <= n; ++i) {

c = a

if (c ~ /[a-z]/) rv = rv toupper(c)
else rv = rv tolower(c)
}

return rv
}
{ print switchcase($0) }
 
something like this:
Code:
{
  s=""
  for(i=1; i<=length; i++) {
     c=substr($0, i, 1)
     s = s ((c ~ /[a-z]/) ? toupper(c) : tolower(c))
  }
  print s
}

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top