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

explanation for regex needed

Clemenss
Active Contributor
0 Likes
658

Hi intellectuals,

the new regex functionality is really amazing - but not easy to understand.

Let me try to start a small competition:

Pleas explain in detail the following expression:


DATA:
  whatever TYPE string,
  matcher TYPE REF TO cl_abap_matcher.

matcher = cl_abap_matcher=>create( 
            pattern = `w+(.w+)*@(w+.)+(w{2,4})`
            text    = whatever ).

I'd like to know the evaluation check procedure matcher->match( ). Just imagine what could I put into string whatever to match or not match the expression pattern.

TIA,

Regards,

Clemens

4 REPLIES 4
Read only

Former Member
0 Likes
592

Hey,

maybe this on is a bit late... \w is a group of characters containing any word usually this one \[A-Za-z0-9_\]...

But you may check out this [website|http://www.regular-expressions.info/charclass.html] which i found quite amazing helpfull.

And your code is probably a mailadress...

Edited by: Rumpf Johannes on Feb 12, 2008 4:00 PM

Edited by: Rumpf Johannes on Feb 12, 2008 4:01 PM

Read only

Clemenss
Active Contributor
0 Likes
592

OK, I played with REGEX in ABAP. Some drawbacka remain because there is no ISO or other common definition of regualr expressions and the results of more complex expressions may be different for different languages and applications.

For instance MS WORD search & replace with patterns activated interprets regular expressions including back references, ABAP did not support back references when I tried.

Hopefully, an UN or ISO definition will be written down soon. For the time being it may be helpful if SAP tells us at least where the ABAP regex has differences compared with i.e. Regular Expressions in Single UNIX ® Specification, Version 2 (http://regexlib.com/DisplayPatterns.aspx)

Regards, Clemens

Read only

Former Member
0 Likes
592

Hi,

I also played with regular expressions in ABAP and other tools. And every tool worked a little bit different. According to the SAP documentation is ABAP using the [Boost Regex Library|http://www.boost.org/].

Cause it is not very easy to implement REGEX machines I am not wondering why there are such differents in behaviour. But why ABAP behaves different when using FIND REGEX and the regex classes that is still a not answered question -> and .

Regards Rudi

Read only

Former Member
0 Likes
592

Hi,

i think, i've read that ABAP uses the POSIX standard for RegEx. My experience is to use in windows tools like "textpad" to test my regular expressions.

reg, JR