0

While ApEx has an inbuilt character counter, I want to show the number of words entered as the user enters text into a textarea.

How would I go about achieving this?

  • Possible duplicate of [Counting and limiting words in a textarea](https://stackoverflow.com/questions/17909646/counting-and-limiting-words-in-a-textarea) – Rene Jun 16 '17 at 05:55

2 Answers2

0

Easiest way is to calculate the string length minus the string length after removing (single) whitespaces and then adding one. For example,

(length(text) - length(text, ' ',''))+1

This may not work if your text has multiple white space. You may wanna replace multiple whitespace with a single one, before doing this.

Sejal Parikh
  • 153
  • 10
0

You can count number of white spaces and then add one to it. That would be a simple word counter. Regexp_count comes handy in this: https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions135.htm#SQLRF20014

SELECT REGEXP_COUNT('This is my life.', ' ', 1, 'i')+1 word_count FROM DUAL; 
Sejal Parikh
  • 153
  • 10