That doesn't seem to work with digits SELECT substring('12.00.00.34' FROM $$((\d+)\.\2)$$); or SELECT substring('12.00.00.34' FROM $$((\w+)\.\2)$$); but works with strings SELECT substring('abc.foo.foo.xyz' FROM $$((\w+)\.\2)$$); What I basically want to do is have a slice function like Python, where I can slice out items from a \s, \. or \n\n separated list. Where I could start it at a certain point and end it at another. Like slicing out paragraph 3-6 (delimiter \n\n) or the 2nd-6th sentence in a article (delimiter \.). That is what I am trying to do. I know if I can figure how to get that working I can figure out how to deal with extending it/handling misc. characters/etc in pgsql. I only need a working vanilla example. Thanks for all you help. --- Michael Fuhr <mike@xxxxxxxx> wrote: > SELECT substring('abc.foo.foo.xyz' FROM > '(([[:alpha:]]+)\\.\\2)'); > substring > ----------- > foo.foo > (1 row) > > That is, one or more alphabetic characters followed > by a dot followed > by the same set of characters (this is a simplistic > example: it would > also match 'foo.oog' and return 'oo.oo'). > > Note that the back reference is \2 because it refers > to the inner > set of parentheses (i.e., the subexpression with the > second opening > parenthesis); the outer set is used here for > capturing. And again, > note the escaped backslashes because we're using > ordinary quotes. > With dollar quotes the above query would be: > > SELECT substring('abc.foo.foo.xyz' FROM > $$(([[:alpha:]]+)\.\2)$$); > > -- > Michael Fuhr > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your message can get through to the mailing list cleanly