1

I have string like this 125.67.888.66.123. I want to count number of dot operations.

For example:

123.45 => 2

3446.67.88 => 3

23.45.567.88 => 4

I write this query SELECT REGEXP_COUNT ('3.222.123.44.1055', '.') FROM dual;

But it gives 16.How can i obtain 5 for above query.When i find exact number I will start a loop.Do you have any idea?

tom
  • 185
  • 8
  • Does this answer your question? [What special characters must be escaped in regular expressions?](https://stackoverflow.com/questions/399078/what-special-characters-must-be-escaped-in-regular-expressions) – Ryszard Czech Nov 09 '20 at 20:43

1 Answers1

2

You need to escape . -- and to add 1:

SELECT REGEXP_COUNT('3.222.123.44.1055', '[.]') + 1
FROM dual; 
Gordon Linoff
  • 1,198,228
  • 53
  • 572
  • 709