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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting from a string field

Status
Not open for further replies.

akirk

Technical User
Mar 28, 2002
27
US
I need to figure a way to suppress vowels from a string of company names. For example, Ford would return Frd etc

any ideas?

thanks

kirk
 
Forgot to mention I am using CR 7

kirk
 
try this code...loop through the string character by character...check for a vowel and build a new string if its not.


stringvar str_with_vowels:= {DATABASE.FIELD};
stringvar str_without_vowels;
stringvar currentchar;
numbervar i:=1;

str_without_vowels:= "";
currentchar:= "";
for i:= 1 to len(str_with_vowels) do
(
currentchar:= str_with_vowels;
select currentchar
case "a","e","i","o","u","A","E","I","O","U":
""
default:
str_without_vowels:= str_without_vowels + currentchar;

);


str_without_vowels;
 
I don't think v7 is going to like that. You might have to find yourself using a pretty comprehensive Instr argument.
 
Try this:
replace(replace(replace(replace(replace({your.field},"a",""),"e",""),"i",""),"o",""),"u","") Mike

 
Tman, Tek-tips doesn't like you using _[_i_] in your submission! Try using j from now on! I learnt that yesterday. Steve Phillips, Crystal Consultant
 
...Or just surrounding your proposed code with [ignore]
Code:
MyCode
[/ignore].

Mike's nice and tidy solution is the way to go here, I think, Kirk, though you might want to try applying 'LowerCase' to the name field in the formula to take care of companies starting off with capital vowels.

Naith
 
Sorry about that...I'll pay a little closer attention to my code tags next time. And frankly, I like Mikes solution better than mine anyway and it works in V7.

Regards
 
Thanks for all the help--the replace function does not seem to be recognized by crystal...

Trying to see if I can find it.

kirk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top