Solved

perl tr/y like function

Posted on 2004-09-03
4
1,301 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
innerHTML 7 35
Load data upon clicking a button 8 35
Filktering Alphabetically 8 32
Add a Location and Color Price based on select box selected option 17 52
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

828 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