Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find number within string
Message
From
06/07/1999 12:14:38
 
 
To
06/07/1999 11:55:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237774
Message ID:
00237810
Views:
11
>PMFJI -- One caveat that occured to me with these commands everyone has offered is that they will pull ALL of the numbers out of the string, ie:
>
>2nd #70 blue = 270
>
>You may need to check more carefully to see if there is text between numbers and pull the numbers out seperately. Then again, you may not, and I may be wasting bandwidth :-)
>

If that's the case, simply modify Christof's statement to:

ChrTran(lcString,ChrTran(lcString,"0123456789","")," ")

So that blanks will be inserted for all non-numeric characters; you can then parse the string to your heart's content, looking for whitespace as separators in the string.

>>Hi John,
>>
>>>Is there a way to find a number within a string? Here's the twist, the number could be anywhere in the string, and I want to find any number...like this "#70 blue" or "70 blue" or "blue 70"
>>
>>My suggestion is similar to George's, except that you don't need FoxTool.Fll:
>>
>> ChrTran(lcString,ChrTran(lcString,"0123456789",""),"")
>>
>>The inner chrtran determines all characters that are not digits and are contained in the string. The outer ChrTran removes all of these characters. What remains are the digits. It's the same a StrFilter().
>>
>>Christof
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform