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

Regex with negation not working

Former Member
0 Kudos
640

Hi,


I have this simple ABAP report that it supposed to print out on the screen a message if a string input contains a non-numeric symbol. I use regex '[^0-9]' in order to do that. However, the program never ends up setting sy-subrc to 0, so it never finds a non-numeric symbol in string. Is there something wrong with my regex?

REPORT  Z_SAMPLE.

data: input type c length 4 value '123a'.

find first occurrence of '[^0-9]' in input.

if sy-subrc = 0.

   Write: 'Found non-numeric character in ', input, /.

endif.

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Kudos
276

FIND FIRST OCCURRENCE OF REGEX ..

-- Tomas --
2 REPLIES 2
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Kudos
277

FIND FIRST OCCURRENCE OF REGEX ..

-- Tomas --
Read only

nikolayevstigneev
Contributor
0 Kudos
276

Hi, Jake! 

Tomas is right

Please, refer to the document and you'll start using \D instead of your regex.