Count the number of letters in the string
select regexp_count('ABC123', '[A-Z]') Match_char_ABC_count,
regexp_count('A1B2C3', '[A-Z]') Match_char_ABC_count
from dual
MATCH_CHAR_ABC_COUNT | MATCH_CHAR_ABC_COUNT | 3 | 3 |
---|
Count the letter followed by one digit number in the string
select regexp_count('ABC123', '[A-Z][0-9]') Match_string_C1_count,
regexp_count('A1B2C3', '[A-Z][0-9]') Match_strings_A1_B2_C3_count
from dual
MATCH_STRING_C1_COUNT | MATCH_STRINGS_A1_B2_C3_COUNT | 1 | 3 |
---|
Count the letter followed by a single digit number at the start of a string
select regexp_count('ABC123A5', '^[A-Z][0-9]') Char_num_like_A1_at_start,
regexp_count('A1B2C3', '^[A-Z][0-9]') Char_num_like_A1_at_start
from dual
CHAR_NUM_LIKE_A1_AT_START | CHAR_NUM_LIKE_A1_AT_START | 0 | 1 |
---|
Count the letter followed by exactly two digits number anywhere in the string
select regexp_count('ABC123', '[A-Z][0-9]{2}') Char_num_like_A12_anywhere,
regexp_count('A1B2C34', '[A-Z][0-9]{2}') Char_num_like_A12_anywhere
from dual
CHAR_NUM_LIKE_A12_ANYWHERE | CHAR_NUM_LIKE_A12_ANYWHERE | 1 | 1 |
---|
Count for first two occurrences of a letter followed by a single digit number
select regexp_count('ABC12D3', '([A-Z][0-9]){2}') Char_num_within_2_places,
regexp_count('A1B2C3', '([A-Z][0-9]){2}') Char_num_within_2_places
from dual
CHAR_NUM_WITHIN_2_PLACES | CHAR_NUM_WITHIN_2_PLACES | 0 | 1 |
---|