Solved

perl tr/y like function

Posted on 2004-09-03
4
1,300 Views
Last Modified: 2009-12-16
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.
0
Comment
Question by:ren_b
  • 2
4 Comments
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 100 total points
ID: 11979441
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
 
LVL 6

Author Comment

by:ren_b
ID: 11980444
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
 
LVL 7

Accepted Solution

by:
Xxavier earned 400 total points
ID: 11980666
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
 
LVL 6

Author Comment

by:ren_b
ID: 11980763
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

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question