Difference between revisions of "SAP ABAP REGEX"
From SapWiki
Line 50: | Line 50: | ||
^\d{1,13}$ | ^\d{1,13}$ | ||
+ | |||
+ | ==Regular Expression Patterns== | ||
+ | Escape character | ||
+ | Special character Meaning | ||
+ | \ Escape character for special characters | ||
+ | Special Characters for single character string | ||
+ | Special character Meaning | ||
+ | . Placeholder for any single character | ||
+ | \C Placeholder for any single character | ||
+ | \d Placeholder for any single digit | ||
+ | \D Placeholder for any character other than a digit | ||
+ | \l Placeholder for any lower-case letter | ||
+ | \L Placeholder for any character other than a lower-case letter | ||
+ | \s Placeholder for a blank character | ||
+ | \S Placeholder for any character other than a blank character | ||
+ | \u Placeholder for any upper-case letter | ||
+ | \U Placeholder for any character other than an upper-case letter | ||
+ | \w Placeholder for any alphanumeric character including _ | ||
+ | \W Placeholder for any non-alphanumeric character except for _ | ||
+ | [ ] Definition of a value set for single characters | ||
+ | [^ ] Negation of a value set for single characters | ||
+ | [ - ] Definition of a range in a value set for single characters | ||
+ | [ [:alnum:] ] Description of all alphanumeric characters in a value set | ||
+ | [ [:alpha:] ] Description of all letters in a value set | ||
+ | [ [:blank:] ] Description for blank characters and horizontal tabulators in a value set | ||
+ | [ [:cntrl:] ] Description of all control characters in a value set | ||
+ | [ [:digit:] ] Description of all digits in a value set | ||
+ | [ [:graph:] ] Description of all graphic special characters in a value set | ||
+ | [ [:lower:] ] Description of all lower-case letters in a value set | ||
+ | 2/9/2017 SAP ABAP REGEX - Sapwiki | ||
+ | http://sapwiki.cl/wiki/index.php?title=SAP_ABAP_REGEX 2/5 | ||
+ | [ [:print:] ] Description of all displayable characters in a value set | ||
+ | [ [:punct:] ] Description of all punctuation characters in a value set | ||
+ | [ [:space:] ] Description of all blank characters, tabulators, and carriage feeds in a value set | ||
+ | [ [:unicode:] ] Description of all Unicode characters in a value set with a code larger than 255 | ||
+ | [ [:upper:] ] Description of all upper-case letters in a value set | ||
+ | [ [:word:] ] Description of all alphanumeric characters in a value set, including _ | ||
+ | [ [:xdigit:] ] Description of all hexadecimal digits in a value set | ||
+ | \a \f \n \r \t \v Diverse platform-specific control characters | ||
+ | [..] Reserved for later enhancements | ||
+ | [==] Reserved for later enhancements | ||
+ | Special Characters for character string patterns | ||
+ | Special character Meaning | ||
+ | {n} Concatenation of n single characters | ||
+ | {n,m} Concatenation of at least n and a maximum of m single characters | ||
+ | {n,m}? Reserved for later enhancements | ||
+ | ? One or no single characters | ||
+ | * Concatenation of any number of single characters including 'no characters' | ||
+ | *? Reserved for later enhancements | ||
+ | + Concatenation of any number of single characters excluding 'no characters' | ||
+ | +? Reserved for later enhancements | ||
+ | | Linking of two alternative expressions | ||
+ | ( ) Definition of subgroups with registration | ||
+ | (?: ) Definition of subgroups without registration | ||
+ | \1, \2, \3 ... Placeholder for the register of subgroups | ||
+ | \Q ... \E Definition of a string of literal characters | ||
+ | (? ... ) Reserved for later enhancements | ||
+ | Special Characters for search string | ||
+ | Special character Meaning | ||
+ | ^ Anchor character for the start of a line | ||
+ | \A Anchor character for the start of a character string | ||
+ | $ Anchor character for the end of a line | ||
+ | \Z Anchor character for the end of a character string | ||
+ | \< Start of a word | ||
+ | \> End of a word | ||
+ | \b Start or end of a word | ||
+ | \B Space between characters within a word | ||
+ | (?= ) Preview condition | ||
+ | (?! ) Negated preview condition | ||
+ | Special Characters for replacement texts | ||
+ | Special character Meaning | ||
+ | $0, $& Placeholder for the whole found location | ||
+ | $1, $2, $3... Placeholder for the register of subgroups | ||
+ | $` Placeholder for the text before the found location | ||
+ | |||
[[:Categoría:ABAP]] | [[:Categoría:ABAP]] |
Revision as of 16:05, 26 March 2020
Ejemplos REGEX
- validar rut (muy simple)
FIND REGEX '[0-9]{1,8}-([0-9]|K)' IN l_strng.
- valida e-mail
^[^<>()\[\]\\,;:\s@"`]+@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$
- validar Números
validar número 1.1111 correcto -1.1111 correcto 1.11111- correcto 1111 correcto
^[-?0-9]+([.])?([0-9]+)?-?$
números de 2 enteros y 7 decimales 1.1234567 correcto 11.1234560 correcto
^[0-9]{1,2}\.([0-9]{7})+$
con signo izquierda -1.1234567 correcto 1.1234567 correcto
^-?[0-9]{1,2}\.([0-9]{7})+$
con signo derecha o izquierda ^-?[0-9]{1,2}\.([0-9]{7})+-?$
validar número entero ^[0-9]+$
numero NNN.NN valido 111.1 11.11 1
^\d{1,3}(\.\d{1,2})?$
numero entero con máximo de 13 caracteres valido 1234567890111 111 1
^\d{1,13}$
Regular Expression Patterns
Escape character Special character Meaning \ Escape character for special characters Special Characters for single character string Special character Meaning . Placeholder for any single character \C Placeholder for any single character \d Placeholder for any single digit \D Placeholder for any character other than a digit \l Placeholder for any lower-case letter \L Placeholder for any character other than a lower-case letter \s Placeholder for a blank character \S Placeholder for any character other than a blank character \u Placeholder for any upper-case letter \U Placeholder for any character other than an upper-case letter \w Placeholder for any alphanumeric character including _ \W Placeholder for any non-alphanumeric character except for _ [ ] Definition of a value set for single characters [^ ] Negation of a value set for single characters [ - ] Definition of a range in a value set for single characters [ [:alnum:] ] Description of all alphanumeric characters in a value set [ [:alpha:] ] Description of all letters in a value set [ [:blank:] ] Description for blank characters and horizontal tabulators in a value set [ [:cntrl:] ] Description of all control characters in a value set [ [:digit:] ] Description of all digits in a value set [ [:graph:] ] Description of all graphic special characters in a value set [ [:lower:] ] Description of all lower-case letters in a value set 2/9/2017 SAP ABAP REGEX - Sapwiki http://sapwiki.cl/wiki/index.php?title=SAP_ABAP_REGEX 2/5 [ [:print:] ] Description of all displayable characters in a value set [ [:punct:] ] Description of all punctuation characters in a value set [ [:space:] ] Description of all blank characters, tabulators, and carriage feeds in a value set [ [:unicode:] ] Description of all Unicode characters in a value set with a code larger than 255 [ [:upper:] ] Description of all upper-case letters in a value set [ [:word:] ] Description of all alphanumeric characters in a value set, including _ [ [:xdigit:] ] Description of all hexadecimal digits in a value set \a \f \n \r \t \v Diverse platform-specific control characters [..] Reserved for later enhancements [==] Reserved for later enhancements Special Characters for character string patterns Special character Meaning {n} Concatenation of n single characters {n,m} Concatenation of at least n and a maximum of m single characters {n,m}? Reserved for later enhancements ? One or no single characters * Concatenation of any number of single characters including 'no characters' *? Reserved for later enhancements + Concatenation of any number of single characters excluding 'no characters' +? Reserved for later enhancements | Linking of two alternative expressions ( ) Definition of subgroups with registration (?: ) Definition of subgroups without registration \1, \2, \3 ... Placeholder for the register of subgroups \Q ... \E Definition of a string of literal characters (? ... ) Reserved for later enhancements Special Characters for search string Special character Meaning ^ Anchor character for the start of a line \A Anchor character for the start of a character string $ Anchor character for the end of a line \Z Anchor character for the end of a character string \< Start of a word \> End of a word \b Start or end of a word \B Space between characters within a word (?= ) Preview condition (?! ) Negated preview condition Special Characters for replacement texts Special character Meaning $0, $& Placeholder for the whole found location $1, $2, $3... Placeholder for the register of subgroups $` Placeholder for the text before the found location