Page 1 of 1

How to read the numeric part of a string in PX

Posted: Mon Dec 26, 2005 5:38 am
by Abhijeet
Hi is there any built-in function to read only the numeric characters of a string

Posted: Mon Dec 26, 2005 6:03 am
by ArndW
Yes, there are several built-in functions in PX. The one you choose depends upon the stage where you are looking to do this and whether the number is an integer or a floating point one. Please look into you documentation and you can use the search string "from_string" to get some of the functions - or at least find the appropriate starting point.

Posted: Mon Dec 26, 2005 7:24 am
by kumar_s
Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar

Posted: Mon Dec 26, 2005 9:47 pm
by Abhijeet
the "from_string" functions convert numeric string to decimal/float .
String_to_decimal or decimal_from_string function returns me 0.0 on a alphanumeric string.

Whereas i want to extract all the numeric characters from a alphanumeric string.

Eg: string-> 123fre233

should return me 123 {numeric characters until first non-numeric character is encountered.}
Here 233 is discarded.

Posted: Mon Dec 26, 2005 9:55 pm
by Abhijeet
kumar_s wrote:Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar
Hi kumar ,

The input string can have alphanumeric , whitespaces and symbols . Out of this I have to extract only the numeric part. So in such case using convert func wont be feasible. :(

Posted: Mon Dec 26, 2005 10:05 pm
by chulett
Abhijeet wrote:Whereas i want to extract all the numeric characters from a alphanumeric string.

Eg: string-> 123fre233

should return me 123 {numeric characters until first non-numeric character is encountered.}
Just wanted to point out that 'all numeric characters' and 'numeric characters until the first non-numeric character' are two totally different things. :wink:

Posted: Mon Dec 26, 2005 11:26 pm
by Abhijeet
True, lets stick to extracting all numeric characters from a string . :)
So is it possible in PX without me writing any routines ?

Posted: Tue Dec 27, 2005 4:15 am
by ArndW
Abhijeet,

no, there is no builtin function in PX to do what you want.

Posted: Tue Dec 27, 2005 8:09 am
by kumar_s
Abhijeet wrote:
kumar_s wrote:Hi,
Yes as Arnd mentioned you have many approach.
You can also use CONVERT to convert all the alphabet into 0 or 1 according to your requirement.
Hence the left out value will be purely numeric.

-Kumar
Hi kumar ,

The input string can have alphanumeric , whitespaces and symbols . Out of this I have to extract only the numeric part. So in such case using convert func wont be feasible. :(
Hi,
Yes it may be feasible if you convert all the alpahabets,whitespace,symbols to space and use FIELD funciton to locate the first Space. Or trim all space and convert to numeric.

-Kumar