String function to Find how many times str2 is in str1?

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: String function to Find how many times str2 is in str1?
Date: 2008-02-15 16:09:40
Message-ID: 47B5B944.4010203@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Good morning,

Is there a string function in PSQL to count how many times one str is in
another string?

For example,
Str1 = "test test caa dtest testing EndofString";
Str2 = " ";

select funcName(Str1, Str2);

return 5

Because Str1 has 5 Str2.

Thanks !
Ly

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rodrigo E. De León Plicet 2008-02-15 17:46:22 Re: String function to Find how many times str2 is in str1?
Previous Message Bart Degryse 2008-02-15 13:00:17 Re: Function description