Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:31:02+00:00 2026-06-17T11:31:02+00:00

This is a follow up question to a post here Regex for matching last

  • 0

This is a follow up question to a post here Regex for matching last two parts of a URL

I was wondering if I could use built in sql funcitons to accomplish the same type of pattern match without using regular expressions. In particular I was thinking if there was a way to reverse the string say http://www.stackoverflow.com to com.stackoverflow.www and then apply concatenation to split(‘com.stackoverflow.www , ‘.’, 1) || split(‘com.stackoverflow.www , ‘.’, 2) I would be done but I am not sure if this is possible.

Here is the general problem description:

I am trying to figure out the best sql function simply match only the last two strings seperated by a . in a url.

For instance with http://www.stackoverflow.com I just want to match stackoverflow.com

The issue i have is some strings can have a large number of periods for instance

a-abcnewsplus.i-a277eea3.rtmp.atlas.cdn.yimg.com

should also return only yimg.com

The set of URLS I am working with does not have any of the path information so one can assume the last part of the string is always .org or .com or something of that nature.

What sql functions will return stackoverflow.com when run against http://www.stackoverflow.com and will return yimg.com when run against a-abcnewsplus.i-a277eea3.rtmp.atlas.cdn.yimg.com under the conditions stated above? I did not want to use regular expressions in the solution just sql string manipulation functions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:31:03+00:00Added an answer on June 17, 2026 at 11:31 am

    doesn’t look like you can do it with 8.3 function set http://www.postgresql.org/docs/8.3/static/functions-string.html

    there’s no reverse – that comes in 9.1. with that you could do:

    select reverse(split_part(reverse(data), '.', 2)) || '.'
        || reverse(split_part(reverse(data), '.', 1))
    from example;
    

    see http://sqlfiddle.com/#!1/25e43/2/0

    you can declare your own reverse: http://a-kretschmer.de/diverses.shtml and then solve this problem.

    but regex is just easier…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is a follow-up question to my last one here: iOS: Initialise object at
this is a follow-up question to my last one here: iOS: Initialise object at
This post is a follow-up of a related question posted here by Ran .
This is a follow-up question related to my previous post . Below is a
This post if a follow-up question to mt previous post: Android RESTful Web application
This is a follow-on question from the one I asked here . Can constraints
this is a follow-up question of mine. Suppose now I have a URL :
This is a follow up to the question asked here: Groovy parsing text file
This is a kind of follow-up question to this post, where the coloring of
This is a follow up to my question earlier here: Android: Autocomplete TextView Similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.