Skip site navigation (1) Skip section navigation (2)

How to find the position of a characted in a string

From: ss_postgres <ss(dot)postgres(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: How to find the position of a characted in a string
Date: 2008-12-08 06:30:00
Message-ID: 6c1264780812072230v6d89cbf4hf618c035d98319b4@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
Hi,

I am trying to find the position of a character in a string which appears
multiple times.

The POSITION function returns the position of the character when it first
occurs.

For eg:

select position ( ' ' in 'Hi How are you');

This returns the result as "3".


But i need to result to be

3
7
11


Can anyone please let me know what would be the best way to do this.

Thanks

Responses

pgsql-admin by date

Next:From: Pawel SochaDate: 2008-12-08 07:14:22
Subject: Re: How to find the position of a characted in a string
Previous:From: AmitKumar JainDate: 2008-12-08 02:39:42
Subject: pg_service.con

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group