Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find number within string
Message
From
06/07/1999 22:26:53
 
 
To
06/07/1999 17:20:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00237774
Message ID:
00238090
Views:
15
>>Oh, crud! Slight correction:
>>Change
>>
>  lnNum = SUBSTR( lcString, lni )
>>to
>>
lnNum = VAL( SUBSTR( lcString, lni ) )
>>
>>Sorry, 'bout that.
>
>I'll jump in here
>
>lcNumber = ""
>FOR lnCount = 1 TO LEN(lcOrigStr)
> IF ISDIGIT(SUBSTR(OrigStr, lnCount, 1))
> lcNumber = lcNumber + SUBSTR(OrigStr, lnCount, 1)
> ENDIF
>ENDFOR


Hi, all. As previously Todd said "2nd # 70Blue" will give "270" result but
actually there is no continuous "270" string in it..

So, at else part adding space or other character to separate it.

lcNumber = ""
lPrevIsDigit = .F.   && don't add more space if already added!
FOR lnCount = 1 TO LEN(lcOrigStr)
   IF ISDIGIT(SUBSTR(OrigStr, lnCount, 1))
      lcNumber = lcNumber + SUBSTR(OrigStr, lnCount, 1)
      lPrevIsDigit = .T.
   ELSE
      If lPrevIsDigit
         lcNumber = lcNumber + " "
      Endif
      lPrevIsDigit = .F.
   ENDIF
ENDFOR


Actually, back to the original need, maybe we have made a wrong & long direction!

John, do you know you can simply use $ , AT(), and like() to search whether your needed numeric string exist or not in string?!

e.g.

Use Customer again in 0 order tag cust_no shared
Set filter to [123]$CustTel

* Only CustTel field contain [123] number is filter out, else hide!!

? AT([123], CustTel) && will show the start position (number) of 123 string

list field cust_no, CustTel for CustTel like "%123_456%"

* % is multi-wild card same as * BUT use % here!!
* _ is single wild card same as ? BUT use _ here!!

list field cust_no, CustTel For Like("*123?456", CustTel)

* will do the same thing as preview cmd, but use different wild card syntax...

~_~ Good Luck!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform