Application Development 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: 

What is the regular expression for T1234567893 in SAP?

Former Member
0 Kudos

Hi,

I would like to search for   T1234567893 in a string with FIND ALL OCCURENCES OF REGEX....

T never change but the following 10 digits do.

I have tried this and it didnt work: T*[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]

Thanks.

5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos

Hi Maria,

and what about   CP  :

Covers Pattern: True, if the content of operand1 fits the pattern in operand2. Wildcard characters can be used to create the operand2 pattern, where "*" represents any character string (including a blank string) and "+" represents any character. It is not case-sensitive. Trailing blanks in the left operand are respected. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is false, sy-fdpos contains the length of operand1. You can select characters in operand2 for a direct comparison by adding the escape symbol"#" before the required characters. For characters flagged in this way in operand2, the operator is case-sensitive. Also, wildcard characters and the escape symbol are not subject to special handling and trailing blanks are relevant.

regards

Fred

raymond_giuseppi
Active Contributor
0 Kudos

Execute report RS_SIC_REGEX_CHECK, try with string "AAAT123456BB" and regex "T[0-9][0-9][0-9][0-9][0-9][0-9]" or "T[0-9]{6}", then read its source.

Regards,

Raymond

hendrik_brandes
Contributor
0 Kudos

Hello Maria,

I would try to use this pattern:

T([0-9]{10})

Try it with the report DEMO_REGEX_TOY:

When using this expression you should also replace the numer-part with something else.

Kind regards,

Hendrik

0 Kudos

I was not aware of this report RS_SIC_REGEX_CHECK screen is less attractive...

0 Kudos

DEMO_REGEX_TOY is the best way to learn regular expressions in ABAP.

I would like to mention an alternative to get the match.

Expression (T\d{10}) would match T1234567893 and give same thing as submatch, whereas T(\d{10}) would match T1234567893, and return submatch as 1234567893.

Parenthesis ( ) are used to get enclosed part of pattern as submatch.

Curly brackets { } are used to specify the number of occurrences. Patterns [0-9][0-9][0-9],  \d\d\d , \d{3} are same.