Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support FIND REGEX RESULTS #147

Closed
larshp opened this issue Dec 2, 2020 · 2 comments
Closed

support FIND REGEX RESULTS #147

larshp opened this issue Dec 2, 2020 · 2 comments
Assignees

Comments

@larshp
Copy link
Member

larshp commented Dec 2, 2020

https://github.com/abaplint/transpiler/blob/master/packages/runtime/src/statements/find.ts

@larshp larshp changed the title support FIND REGEX SUBMATCHES support FIND REGEX RESULTS Dec 2, 2020
@larshp larshp self-assigned this Dec 10, 2020
@larshp
Copy link
Member Author

larshp commented Dec 10, 2020

basic test case,

TYPES: BEGIN OF ty_submatch,
         offset TYPE i,
         length TYPE i,
       END OF ty_submatch.

TYPES: BEGIN OF ty_match,
         line       TYPE i,
         offset     TYPE i,
         length     TYPE i,
         submatches TYPE STANDARD TABLE OF ty_submatch WITH DEFAULT KEY,
       END OF ty_match.

DATA lt_matches TYPE STANDARD TABLE OF ty_match WITH DEFAULT KEY.
DATA ls_match LIKE LINE OF lt_matches.
DATA ls_submatch LIKE LINE OF ls_match-submatches.

FIND REGEX |bar| IN |hello bar world| RESULTS lt_matches.
ASSERT lines( lt_matches ) = 1.
READ TABLE lt_matches INDEX 1 INTO ls_match.
ASSERT ls_match-line = 0.
ASSERT ls_match-offset = 6.
ASSERT ls_match-length = 3.
ASSERT lines( ls_match-submatches ) = 0.

FIND REGEX |(bar)| IN |hello bar world| RESULTS lt_matches.
ASSERT lines( lt_matches ) = 1.
READ TABLE lt_matches INDEX 1 INTO ls_match.
ASSERT lines( ls_match-submatches ) = 1.
READ TABLE ls_match-submatches INDEX 1 INTO ls_submatch.
ASSERT ls_submatch-offset = 6.
ASSERT ls_submatch-length = 3.

@larshp
Copy link
Member Author

larshp commented Dec 10, 2020

done, closing

@larshp larshp closed this as completed Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant