How to read the numeric part of a string in PX
Moderators: chulett, rschirm, roy
How to read the numeric part of a string in PX
Hi is there any built-in function to read only the numeric characters of a string
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.
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.
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.
Hi kumar ,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
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.
![Sad :(](./images/smilies/icon_sad.gif)
Just wanted to point out that 'all numeric characters' and 'numeric characters until the first non-numeric character' are two totally different things.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.}
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hi,Abhijeet wrote:Hi kumar ,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
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.
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