pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
regular expression
5+ messages / 4 participants
[nested] [flat]

* regular expression
@ 2005-10-03 22:08 gurkan@resolution.com
  2005-10-05 04:56 ` Re: regular expression Gnanavel S <s.gnanavel@gmail.com>
  2005-10-05 05:56 ` Re: regular expression Michael Fuhr <mike@fuhr.org>
  0 siblings, 2 replies; 5+ messages in thread

From: gurkan@resolution.com @ 2005-10-03 22:08 UTC (permalink / raw)
  To: pgsql-sql; +Cc: gurkan@resolution.com

How do I do regular expression for the problem that I am having
I have a string called desc, and say that this string in 

"TSWUU"          ------ ""
"4 - DSC"        ------ "4"
"6768 - THY"     ------ "6768"

 basically string may or may not start with number, 
I need substring of digits parts
""
"4"
"6768"

-------------------------------------------------
This mail sent through IMP: www.resolution.com



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: regular expression
  2005-10-03 22:08 regular expression gurkan@resolution.com
@ 2005-10-05 04:56 ` Gnanavel S <s.gnanavel@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Gnanavel S @ 2005-10-05 04:56 UTC (permalink / raw)
  To: gurkan@resolution.com <gurkan@resolution.com>; +Cc: pgsql-sql

Try this,
select substring('6768 - THY','[0-9]*');
substring
-----------
6768
(1 row)

On 10/4/05, gurkan@resolution.com <gurkan@resolution.com> wrote:
>
> How do I do regular expression for the problem that I am having
> I have a string called desc, and say that this string in
>
> "TSWUU" ------ ""
> "4 - DSC" ------ "4"
> "6768 - THY" ------ "6768"
>
> basically string may or may not start with number,
> I need substring of digits parts
> ""
> "4"
> "6768"
>
> -------------------------------------------------
> This mail sent through IMP: www.resolution.com <http://www.resolution.com;
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>



--
with regards,
S.Gnanavel

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: regular expression
  2005-10-03 22:08 regular expression gurkan@resolution.com
@ 2005-10-05 05:56 ` Michael Fuhr <mike@fuhr.org>
  1 sibling, 0 replies; 5+ messages in thread

From: Michael Fuhr @ 2005-10-05 05:56 UTC (permalink / raw)
  To: gurkan@resolution.com; +Cc: pgsql-sql

On Mon, Oct 03, 2005 at 06:08:30PM -0400, gurkan@resolution.com wrote:
> How do I do regular expression for the problem that I am having
> I have a string called desc, and say that this string in 
> 
> "TSWUU"          ------ ""
> "4 - DSC"        ------ "4"
> "6768 - THY"     ------ "6768"
> 
>  basically string may or may not start with number, 
> I need substring of digits parts
> ""
> "4"
> "6768"

See "Pattern Matching" in the documentation:

http://www.postgresql.org/docs/8.0/interactive/functions-matching.html

Example:

test=> SELECT id, data FROM foo;
 id |    data    
----+------------
  1 | TSWUU
  2 | 4 - DSC
  3 | 6768 - THY
(3 rows)

test=> SELECT id, substring(data FROM '^([[:digit:]]+)') FROM foo;
 id | substring 
----+-----------
  1 | 
  2 | 4
  3 | 6768
(3 rows)

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: regular expression
@ 2005-10-12 21:03 Michael Fuhr <mike@fuhr.org>
  2005-10-12 21:55 ` Re: regular expression Yasir Malik <ymalik@cs.stevens.edu>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Fuhr @ 2005-10-12 21:03 UTC (permalink / raw)
  To: gurkan@resolution.com; +Cc: pgsql-sql

[Please copy the mailing list on replies.]

On Wed, Oct 12, 2005 at 04:28:47PM -0400, gurkan@resolution.com wrote:
> Thanks for the reply. It helped a lot. I was goint to ask similar question
> regarding regular expression, but this time I need not the numeric part. What I
> mean is;
> say that this may be in these format 
>  "TSWUU"          ---need--- "TSWUU"
>  "4 - DSC"        ---need--- "DSC"
>  "6768 - THY"     ---need--- "THY"
> basically string may or may not start with number, 
> I need substring of character if it starts with number discard it

This isn't a PostgreSQL issue, but rather one of understanding how
regular expressions work in general.  See the previously mentioned
"Pattern Matching" section of the PostgreSQL documentation for the
PostgreSQL-specific details, and use a search engine to find a
regular expression tutorial; they're frequently used in Perl and
other languages so a lot of learning material exists.  If you can
find a copy in a library or bookstore, the book _Mastering Regular
Expressions_ by Jeffrey E. F. Friedl, published by O'Reilly, is a
good resource.

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: regular expression
  2005-10-12 21:03 Re: regular expression Michael Fuhr <mike@fuhr.org>
@ 2005-10-12 21:55 ` Yasir Malik <ymalik@cs.stevens.edu>
  0 siblings, 0 replies; 5+ messages in thread

From: Yasir Malik @ 2005-10-12 21:55 UTC (permalink / raw)
  To: pgsql-sql

> This isn't a PostgreSQL issue, but rather one of understanding how
> regular expressions work in general.  See the previously mentioned
> "Pattern Matching" section of the PostgreSQL documentation for the
> PostgreSQL-specific details, and use a search engine to find a
> regular expression tutorial; they're frequently used in Perl and
> other languages so a lot of learning material exists.  If you can
> find a copy in a library or bookstore, the book _Mastering Regular
> Expressions_ by Jeffrey E. F. Friedl, published by O'Reilly, is a
> good resource.
>
If you have Perl installed, do a 'man perlretut'.  It is quite a wonderful 
tutorial.  That is what I used to learn regular expressions.

Yasir



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2005-10-12 21:55 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-03 22:08 regular expression gurkan@resolution.com
2005-10-05 04:56 ` Gnanavel S <s.gnanavel@gmail.com>
2005-10-05 05:56 ` Michael Fuhr <mike@fuhr.org>
2005-10-12 21:03 Re: regular expression Michael Fuhr <mike@fuhr.org>
2005-10-12 21:55 ` Yasir Malik <ymalik@cs.stevens.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox