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

How to strip out any number in a field? 2

Status
Not open for further replies.

ziggs

Technical User
Sep 21, 2000
195
US
I have a Crystal Report that has an address field. Within that Address field are the digits, a street name and then a street type. However, sometimes a free format can be used (i.e. Main St/1st St, Taco Bell, Garage area of 123 Main St). Anyway, I need to find a way to take away for numbers in this string. Most of the time, the numbers will be in front, but not always.

Any Direction?

TIA
 
Hi,
By 'take away' what do you mean?

Not show them?
Use them in some formula?
Just display the Numbers?


Please provide a sample of what you would like to see:
( What is in the field vs what you want)
Also,
What Crystal Version?
What database and version?
What connection method?




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Try:

numbervar i;
numbervar j := len({@string});
stringvar x;

for i := 1 to j do(
if isnumeric({@string}) then
x := x else
x := x + {@string});
trim(replace(x," "," "));

-LB
 
lbass,

Just a thought but I think ziggs wants just the address number taken away. I think he just want to take the 123 from 123 Main St.

Otherwise

/1st st

will become

/st st

can we just split the line and check for numeric value on each word?

-lw
 
Unfortunately, garbage in, garbage out. I have to code to make sure that an address does not EVER get published. Thus, I still need to code out 1, in 1st St since the positioning of the digits may, in just a few cases, be in the middle of the record.

I'll play with the lbass's formula in just a bit.

Thanks!
 
You can simplify a bit

numbervar i;
numbervar j := len({@string});
stringvar x;
for i := 1 to j do(
if not(isnumeric({@string})) then
x := x + {@string});
);
trim(x)

-k
 
synapsevampire and lbass's formula works, but for each row it just adds another street until a string is over 254 characters long. I'm still trying to figure out how to reset the variables after it populates for each row.
 
Just add "" to the x variable as below:

numbervar i;
numbervar j := len({@string});
stringvar x := "";

for i := 1 to j do(
if isnumeric({@string}) then
x := x else
x := x + {@string});
trim(replace(x," "," "));

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top