2008 May 27 4:30 PM
hi, gurus,
i have a problem with a validation program for a text string S.
I want to validate that S starts with string A and ends with another string B.
Both A and B are the sets of different strings.
Is RegEX suitable for this program? Is there agile method to solve it?
Thanks,
xiongfei
2008 May 27 4:36 PM
Try this simple logic.
data: lv_str type string value 'ABCaasd;flkajsdf;lkasjXYZ'.
data: lv_begpt type string value 'ABC*'.
data: lv_endpt type string value '*XYZ'.
if lv_str CP lv_begpt
and lv_str cp lv_endpt.
write:/ 'String is valid'.
endif.Regards,
Rich Heilman
2008 May 27 4:34 PM
Hi Welcome to SDN..
vl_total = strlen ( S ).
vl_check = vl_total - 1.
if S+0(vl_total) CS A and if S+vl_check(vl_total) CS B.
2008 May 27 4:36 PM
2008 May 27 4:37 PM
Hi Xiongfei Zhao,
First Find the lenght of the String S using command STRLEN.
STRLEN is used to find the length of the string.
For example suppose the length of the string S is 14.
to find the first charecter use the OFFSET as shown below
data: lw_first type c,
lw_last type c.
lw_first = S+0(1).
lw_last = S+9(1).Best regards,
raam
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |