I am trying to understand the meta character of + symbol in regular expressions. I got a doubt that
SELECT REGEXP_COUNT('RADHA SRI SESHU KOLLA','A') FROM DUAL; Output is 3
SELECT REGEXP_COUNT('RADHA SRI SESHU KOLLA','A+') FROM DUAL; Output is 3
How + makes difference. Can you give me any example?
The plus symbol means match one or more instances of the character before it. You'll notice a difference when you have a series of As next to each other.
For example:
SELECT REGEXP_COUNT('RADHAAA SRI SESHU KOLLA','A') FROM DUAL;
REGEXP_COUNT('RADHAAASRISESHUKOLLA','A')
5
SELECT REGEXP_COUNT('RADHAAA SRI SESHU KOLLA','A+') FROM DUAL;
REGEXP_COUNT('RADHAAASRISESHUKOLLA','A+')
3
The first query only matches the single character A. There are five As in the string, so that's your count.
But the second lumps together any As together. So all those at the end of RADHAAA become one match. So you get three because you have three separate sequences of As.