Application Development 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: 

How to use regular expression to find string

Former Member
0 Kudos

hi,

who know how to get all digits from the string "Alerts 4520 ( 227550 ) ( 98 Available )" by regular expression, thanks

br, Andrew

2 REPLIES 2

Former Member
0 Kudos

hi,

you can use

CO = "contains only",

CA = "contains any".

CN "contains not only"

IF string CO '0123456789'

the string contains only digits

ELSE.

the string contains not only digits (could be no digits at all)

ENDIF.

thanks

former_member194669
Active Contributor
0 Kudos

Liu,

You can use RegEx as


d+

Whether you are using CL_ABAP_REGEX class then


report  zars.
 
data: regex   type ref to cl_abap_regex,
      matcher type ref to cl_abap_matcher,
      match   type c length 1.
 
create object regex exporting pattern = 'd+'
                              ignore_case = ''.
 
matcher = regex->create_matcher( text = 'Test123tes456' ).
 
match = matcher->match( ).
 
write match

You can find more details regarding REGEX and POSIX examples here

http://www.regular-expressions.info/tutorial.html