06-14-2011
change each letter of a string
Is there a way to change each letter of a string to the next one in the alphabet, so that a becomes b and f becomes g, and digits become one unit bigger - 4 becomes 5 and 9 becomes 0.
I want to change strings like ben123 to cfo234.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want get middle two latter of any string.
Input:
var="070108"
output:
var1="01"
please help. (2 Replies)
Discussion started by: rinku
2 Replies
2. Shell Programming and Scripting
How to check whether a particular string contains dot or not?
Here I can not use grep as the string is not in a file. I will get this string from user input
Thanks, (2 Replies)
Discussion started by: balamv
2 Replies
3. Shell Programming and Scripting
Hi,
Pl help me.
User is entering the values for the given input
Enter keys: secret1 secret2 secret3
can i extract the last digit of each values in the keys..
here for ex. 1 2 3
can we get this using shell script? (22 Replies)
Discussion started by: balamv
22 Replies
4. Shell Programming and Scripting
Is there a way to cnvert first letter alone in a string to upper case.
For eg: diamond should be converted to Diamond.
Thanks in Advance,
Kinny (6 Replies)
Discussion started by: kinny
6 Replies
5. Shell Programming and Scripting
Hi
I have e.g. VAR1=january and I need to change it into VAR1=January.
How to change value of VAR1 variable to always set first character uppercase and other lowercase ?
thx for help. (9 Replies)
Discussion started by: presul
9 Replies
6. Shell Programming and Scripting
I am trying to make a script that takes a word and each letter up and turns it into a separate variable. My code currently does not work but I feel I just need to tweak one thing that I am unsure of.
(ex: if forum was typed in letter1=f; letter2=o; letter3=r;...)
Thank you
count=1;
... (7 Replies)
Discussion started by: crimputt
7 Replies
7. Shell Programming and Scripting
i would like to search for a letter in a string and get its index position.
example:
name='john'
pos=$(expr index $name o)
the result will be equal to 2 (2nd position)
how do you make this thing not case sensitive?
example:
name='john'
pos=$(expr index $name O)
the... (1 Reply)
Discussion started by: kokoro
1 Replies
8. Shell Programming and Scripting
Hi all,
I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like
. ; : ! ?I found the following command
sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies
9. Shell Programming and Scripting
Hi,
I have written the following python snippet to store the capital letter starting words into a dictionary as key and no of its appearances as a value in this dictionary against the key.
#!/usr/bin/env python
import sys
import re
hash = {} # initialize an empty dictinonary
for line in... (1 Reply)
Discussion started by: royalibrahim
1 Replies
10. Shell Programming and Scripting
Hello
I'm writing a handler for ffmpeg, and having troubles to catch some exceptions that may occour with certain files.
In order to parse for video & subtitle maps, i've had to make the raw data easier to handle, until now this worked well, but basicly i've just been lucky...
The input... (1 Reply)
Discussion started by: sea
1 Replies
LEARN ABOUT REDHAT
text::soundex
Text::Soundex(3pm) Perl Programmers Reference Guide Text::Soundex(3pm)
NAME
Text::Soundex - Implementation of the Soundex Algorithm as Described by Knuth
SYNOPSIS
use Text::Soundex;
$code = soundex $string; # get soundex code for a string
@codes = soundex @list; # get list of codes for list of strings
# set value to be returned for strings without soundex code
$soundex_nocode = 'Z000';
DESCRIPTION
This module implements the soundex algorithm as described by Donald Knuth in Volume 3 of The Art of Computer Programming. The algorithm is
intended to hash words (in particular surnames) into a small space using a simple model which approximates the sound of the word when spo-
ken by an English speaker. Each word is reduced to a four character string, the first character being an upper case letter and the remain-
ing three being digits.
If there is no soundex code representation for a string then the value of $soundex_nocode is returned. This is initially set to "undef",
but many people seem to prefer an unlikely value like "Z000" (how unlikely this is depends on the data set being dealt with.) Any value
can be assigned to $soundex_nocode.
In scalar context "soundex" returns the soundex code of its first argument, and in list context a list is returned in which each element is
the soundex code for the corresponding argument passed to "soundex" e.g.
@codes = soundex qw(Mike Stok);
leaves @codes containing "('M200', 'S320')".
EXAMPLES
Knuth's examples of various names and the soundex codes they map to are listed below:
Euler, Ellery -> E460
Gauss, Ghosh -> G200
Hilbert, Heilbronn -> H416
Knuth, Kant -> K530
Lloyd, Ladd -> L300
Lukasiewicz, Lissajous -> L222
so:
$code = soundex 'Knuth'; # $code contains 'K530'
@list = soundex qw(Lloyd Gauss); # @list contains 'L300', 'G200'
LIMITATIONS
As the soundex algorithm was originally used a long time ago in the US it considers only the English alphabet and pronunciation.
As it is mapping a large space (arbitrary length strings) onto a small space (single letter plus 3 digits) no inference can be made about
the similarity of two strings which end up with the same soundex code. For example, both "Hilbert" and "Heilbronn" end up with a soundex
code of "H416".
AUTHOR
This code was implemented by Mike Stok ("stok@cybercom.net") from the description given by Knuth. Ian Phillipps ("ian@pipex.net") and Rich
Pinder ("rpinder@hsc.usc.edu") supplied ideas and spotted mistakes.
perl v5.8.0 2002-06-01 Text::Soundex(3pm)