Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to get numeric part from a string.

Former Member
0 Likes
802

Plz help me

how to get numeric part from a string.

Eg. 17682442basic

i want the numeric part from the field ( numeric field length not fixed)

Plz help me

how to get numeric part from a string.

Eg. 17682442basic

i want the numeric part from the field ( numeric field length not fixed)

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
704

Ignore

Edited by: Keshav.T on Oct 18, 2010 6:37 PM

Read only

Former Member
0 Likes
704

Hi,

Check the position of last character by using CA '0123456789'. And upto that position cut the string.

Amitava

Read only

Former Member
0 Likes
704

I'd read the string left to right, one character at a time, until I found a character not in 1-9, by incrementing a counter and doing if string+counter(1) co '123456789'. etc.. When non-numeric character, the index (counter) is the length of the numeric part of the string.

Read only

Former Member
0 Likes
704

Hi,

Try:

data: w_ss(10),
      w_nn type i,
      w_ii type i.

w_ss = '123abc'.
w_ii = 0.
while w_ii < strlen( w_ss ).
  if not w_ss+w_ii(1) ca '0123456789'.
     w_ss+w_ii(1) = ' '.
  endif.
  w_ii = w_ii + 1.
endwhile.
condense w_ss  no-gaps.

w_nn = w_ss.

write w_nn.

Best regards,

Lendro Mengue

Read only

Former Member
0 Likes
704

Moderator message - Please do not ask or answer basic questions or questions that are easily searchable - thread locked Rob