2010 Oct 25 7:27 AM
Hello ABAPers ,
I have to restrict my string to the char's mentioned below :
A to Z
Ä Ö Ü
a to z
ä ö ü
ß 0 to 9
! " § % & / ( ) = ' + * , ; . : -
Am using the following code to do tht but it doesn't work . Would appreciate any help.
gv_string = 'ab1@'.
gv_pattern = '[A-Za-z0-9!"§%&/()=+*,;.:-ß]*'.
TRY.
CREATE OBJECT gx_regex
EXPORTING
pattern = gv_pattern.
CATCH cx_sy_regex .
ENDTRY.
TRY.
CREATE OBJECT gx_matcher
EXPORTING
regex = gx_regex
text = gv_string.
CATCH cx_sy_matcher .
ENDTRY.
*gt_match_result2 = gx_matcher->find_all( ).
match = gx_matcher->match( ).Thanks ,
Sri
Edited by: Matt on Oct 25, 2010 4:27 PM - added tags
2010 Oct 25 2:20 PM
Hello Srivijaya,
You should modify your pattern : since you want any character in the list provided, you should encapsulate it into brackets :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]'But since you have more than one character, you should repeat it n times with a star (*) after it :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'Last thing, '-' is a special character which means for an interval, so you have to escape it with a basckslash :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'And in order to test this easily, you can directly use it like this :
DATA : gv_string TYPE string,
gv_pattern TYPE string,
match TYPE flag.
gv_string = 'ab1@'.
gv_pattern = '[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'.
TRY.
CALL METHOD cl_abap_matcher=>matches
EXPORTING
pattern = gv_pattern
text = gv_string
RECEIVING
success = match.
CATCH cx_sy_regex.
WRITE : 'Unable to evaluate pattern.'.
EXIT.
ENDTRY.Best regards,
Samuel
Hello ABAPers ,
I have to restrict my string to the char's mentioned below :
A to Z
Ä Ö Ü
a to z
ä ö ü
ß 0 to 9
! " § % & / ( ) = ' + * , ; . : -
Am using the following code to do tht but it doesn't work . Would appreciate any help.
gv_string = 'ab1@'.
gv_pattern = '[A-Za-z0-9!"§%&/()=+*,;.:-ß]*'.
TRY.
CREATE OBJECT gx_regex
EXPORTING
pattern = gv_pattern.
CATCH cx_sy_regex .
ENDTRY.
TRY.
CREATE OBJECT gx_matcher
EXPORTING
regex = gx_regex
text = gv_string.
CATCH cx_sy_matcher .
ENDTRY.
*gt_match_result2 = gx_matcher->find_all( ).
match = gx_matcher->match( ).Thanks ,
Sri
Edited by: Matt on Oct 25, 2010 4:27 PM - added tags
2010 Oct 25 7:44 AM
Take a globalvariable and assignit all values and in if clause use CP to implement the same.
Nabheet
2010 Oct 25 2:20 PM
Hello Srivijaya,
You should modify your pattern : since you want any character in the list provided, you should encapsulate it into brackets :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]'But since you have more than one character, you should repeat it n times with a star (*) after it :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'Last thing, '-' is a special character which means for an interval, so you have to escape it with a basckslash :
'[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'And in order to test this easily, you can directly use it like this :
DATA : gv_string TYPE string,
gv_pattern TYPE string,
match TYPE flag.
gv_string = 'ab1@'.
gv_pattern = '[A-Za-z0-9!"§%&/()=+*,;.:-ß*]*'.
TRY.
CALL METHOD cl_abap_matcher=>matches
EXPORTING
pattern = gv_pattern
text = gv_string
RECEIVING
success = match.
CATCH cx_sy_regex.
WRITE : 'Unable to evaluate pattern.'.
EXIT.
ENDTRY.Best regards,
Samuel
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |