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

Replace outputs blank field

Status
Not open for further replies.

JonAtHQ

Technical User
Jun 16, 2005
45
US
When I try to strip hyphens from phone numbers using the following forumla ...

Replace ({EMPLOYEE.TELE_WORK}, "-","")

... the report just contains a blank space, no data. I am certain that the correct field is displayed, and it does have data. The original field contains data like 301-555-1212, and I want it to print as 3015551212.
 
Hi,
It works for me with ' not "..

Replace({HR_PUBLIC.WORK_PHONE_NBR},'-','')

turns

651/290-2222 into 615/2902222





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
There was a problem in 8.0 (that was corrected in 8.5) with the replace function when "" was used to replace a character. Instead of using the replace function, you can try this:

numbervar x := x + 1;
numbervar y := len({table.field});
stringvar z := "";

for x := 1 to y do(
if {table.field}[x] <> "-" then
z := z + {table.field}[x]);
z

-LB
 
Hi,
I did not test it is 8.0 but, as expected., it works with either in 10...

JonAtHQ , what version are you using..


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I'm using 8.0. I was busy today, but will try LBs suggestion today and next week.
 
This worked perfectly. However, I guess I didn't think ahead enough. Since phone numbers in the database do not follow a consistent format, how can I strip any thing else, so that the only output is a string of numbers, with no special characters?

I tried nesting the if/then/else, but wasn't successful.

I want (301) 555-1212 to be 3015551212
I want 301/5551212 to be 3015551212
I want +1 301-555-1212 to be 13015551212

etc.
 
Hi,
A variant of LB's formula should work..

numbervar x := x + 1;
numbervar y := len({table.field});
stringvar z := "";

for x := 1 to y do(
if IsNumeric({table.field}[x]) then
z := z + {table.field}[x]);
z



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Genius, pure genius! I guess I shouldn't have limited my thinking to "I want to remove special characters." Rather, the question could have been asked "I want to print only the numeric values." Thanks. Next up, is to query the record first, and add a "1" if country = US. That and a few other things. I should be able to figure that out, though. If not, I'll be back. For now, it's Miller Time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top