Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 7 Jahren
Letzter Beitrag:
vor 7 Jahren
Beteiligte Autoren:
iso, Marc De Swert, Peter H.

retrieve integers from a string

Startbeitrag von iso am 21.06.2011 09:48

hello

i have a number of fields in a table which i need to extract only the integers from for example here a couple:

Keyrings and Display Stand - 17464 SPINNER - DISPLAY UNIT
Keyrings17465 SPINNER - DISPLAY UNIT
Stand:17468SPINNER - DISPLAY UNIT

as you can see they numbers are placed in different locations throughout each string. Im sure there is a command but i can t seem to find it.

many thanks

iso

Antworten:

Hi iso

perhaps you can use this

sHlp is string="Keyrings and Display Stand - 17464 SPINNER - DISPLAY UNIT "
i,j,k , ni, place are int
sTemp is int

FOR i=1 TO Length(sHlp)
stemp = Asc(sHlp[[i]])
IF ((stemp >= 65 AND stemp = 97 AND stemp = 48 AND stemp

von Marc De Swert - am 21.06.2011 10:08
Hello Marc,

thanks for taking your time to try and hlep me with this

I have approx 12k of these fields in a table id really like to be able to use a formula in an sql statement to show the new values eg i would like ot tooutput for the above cases:

Keyrings and Display Stand - 17464 SPINNER - DISPLAY UNIT
Keyrings17465 SPINNER - DISPLAY UNIT
Stand:17468SPINNER - DISPLAY UNIT

17464
17465
17468

thanks

iso



von iso - am 21.06.2011 10:39
Tweaked your code marc to suit:

sHlp is string=TABLE_QRY_QuickSearch.COL_ItemName
lengthofstring is int = Length(sHlp)
i is int
sTemp is int
sNewval is string


FOR i=1 TO lengthofstring
sTemp = Asc(sHlp[[i]])

IF (sTemp >= 48 AND sTemp

von iso - am 21.06.2011 11:30
Yo Iso,

Nice to here that it works


marc :cool:

von Marc De Swert - am 21.06.2011 11:33
Hi ISO,

A couple of years ago I posted a StringHandler class on the PCSoft repository at www.pcsoft.fr/www.windev.com. It is one of the first items in the repository. It provides numerous stringhandler stuff that isn't provided by standard W-Language.

It also contains a method StripNonNumeric() I believe. You can download the class and source code from the PCSoft site (Repository).

How to use:

StrHndlr is StringHandler
MyAlphaNumericString = StrHndlr:StripNonNumeric(MyAlphaNumericString)

Regards,

Peter


von Peter H. - am 21.06.2011 13:11
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.