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

Former Member
0 Likes
1,034

Hi,

How can I search exactly for f+ in the

'xcdf+fdfrfv' ?

I get right here sy-subrc 0 and its wrong.

I am searching for f+ and not for f

Regards

sas

DATA: moff TYPE i,
      mlen TYPE i,
      s type string.

    s = 'f+'.

FIND REGEX s IN 'xcdfedfrfv'
     MATCH OFFSET moff
     MATCH LENGTH mlen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
997

Try this modified code.

DATA: moff TYPE i,

mlen TYPE i,

s type string.

s = 'f+'.

FIND s IN 'xcdf+edfrfv'

MATCH OFFSET moff

MATCH LENGTH mlen.

write : moff, mlen.

rwrd points if useful

Bhupal

7 REPLIES 7
Read only

Former Member
0 Likes
997

try this way.

if var 'xcdffdfrfv' ca 'f' .

ur logic .

'endif .

Read only

Former Member
0 Likes
998

Try this modified code.

DATA: moff TYPE i,

mlen TYPE i,

s type string.

s = 'f+'.

FIND s IN 'xcdf+edfrfv'

MATCH OFFSET moff

MATCH LENGTH mlen.

write : moff, mlen.

rwrd points if useful

Bhupal

Read only

Former Member
0 Likes
997

hI,

please refer this link related regex pattern

http://www.grymoire.com/Unix/Regular.html#uh-0

Regards

Kiran Sure

Read only

Former Member
0 Likes
997

hi check this..

data: v_char(20) type c value 'xcdf+fdfrfv' .

if v_char ca 'f+' .

write:/ 'the string is found '.

endif .

Read only

karsten_korte
Participant
0 Likes
997

+ Matches the preceding element one or more times. For example, f+ matches "f", "ff", "fff", and so on.

try s = 'f\+'

Read only

Former Member
0 Likes
997

Karsten has solved the problem.

His answer is correctly. But this issue is not

solved completely unless the cascading problem

is not solved.

I must find out a way to prefix \ whether

somebody search e.g. f+.

privously -> s_input-low f+

later -> s_input-low f\+

regards

sas

data lv_string(20) type c.

select-options s_input for lv_string.


DATA: moff TYPE i,
      mlen TYPE i,
      s type string.

translate s_input-low TO LOWER CASE.


FIND REGEX s_input-low IN 'xcdfedfrfv'
     MATCH OFFSET moff
     MATCH LENGTH mlen.

Read only

0 Likes
997

parse the string and escape (\) everything that's not a char or a number or ...

or let the user decide how he want's to search (a lot of search dialog work in this way):

data lv_string(20) type c.

select-options s_input for lv_string.
PARAMETERS p_reg type c as CHECKBOX.


DATA: moff TYPE i,
      mlen TYPE i,
      s type string.

translate s_input-low TO LOWER CASE.

if p_reg is initial.
  FIND s_input-low IN 'xcdfedf+rfv'
       MATCH OFFSET moff
       MATCH LENGTH mlen.
else.
  FIND REGEX s_input-low IN 'xcdfedf+rfv'
       MATCH OFFSET moff
       MATCH LENGTH mlen.
endif.

write: moff, mlen.