perl tr/y like function

is there a tr/// like function. example being translating upper to lower case (and not using toLowerCase) - tr/A-Z/a-z/ or something like tr/0-9/a-j/.

i'm tired - tia.
LVL 6
ren_bAsked:
Who is Participating?
 
XxavierConnect With a Mentor Commented:
There is no such nethod in the stand JS functions see http://www.devguru.com/Technologies/ecmascript/quickref/js_functions.html  the facility is privided as the to LowerCase method of the string object. It can be wrpped in a function as so though.

<script>
 function tr(str){
  return str.toLowerCase()
 }
 str="abcDEFGHijk"
 alert(str+' '+tr(str))
</script>


0
 
ZylochConnect With a Mentor Commented:
Not to my knowledge. You might be able to fudge MOST of them with stringVar.replace(regex,replacement), however.

Also, because tr/// returns the number of matches (if my memory serves me correctly), you'd have to use a separate match like this:

var totalMatches=stringVar.split(regex).length;

0
 
ren_bAuthor Commented:
i'm just looking for a yes or no answer, and if yes, what's the function name. creating it wouldn't be a problem, iff i have to.
0
 
ren_bAuthor Commented:
i wasn't looking for a toLowerCase function - a javascript version of the tr program or tr function in perl - which you say there is no method. that's all i needed to know.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.