regex - Delete spaces, commas, colon, semicolon with regexp -
i trying print number of words in following txt ignoring special characters =,;:'. function works, examples have found here not working properly, i've tried.
the txt is:
select name v$database; select serial# db4sql; clear select (length (txt) - length(regexp_replace(txt, '[0-9\. ,]+$',''))
i trying print number of words in following txt ignoring special characters =,;:'.
any make complex ignore punctuations when need count number of words. simple query using regexp_count , [[:blank:]] character class.
sql> data as( 2 select q'[select name v$database; select serial# db4sql; clear]' txt 3 dual 4 ) 5 select regexp_count(txt, '[^[:blank:]]+') cnt 6 data 7 / cnt ---------- 9 sql>
delete spaces, comas, colon, semicolon regexp
ok. if want replace punctuations , return pure alphabets, use [[:punct:]] character class.
sql> data as( 2 select q'[select name v$database; select serial# db4sql; clear]' txt 3 dual 4 ) 5 select regexp_replace(txt, '[[:punct:]]') cnt 6 data 7 / cnt ---------------------------------------------------------- select name vdatabase select serial db4sql clear sql>