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 7907935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:41:32+00:00 2026-06-03T11:41:32+00:00

the main question is a bit short so I’ll collaborate. I’m building an app

  • 0

the main question is a bit short so I’ll collaborate.
I’m building an app for twitter with which you can do the basic actions (get posts, do a post, reply etc.)

Now I figured it would be a good idea if I’d check the max 140 char limit in my app.
So far so good, then someone asked if I could also do the url-shortener thing.

so at the moment I have a regex that picks op most (in fact too much) url’s, takes the lenght of them and either adds or deduces the difference from the 140 max.
It’s still a but buggy but I can manage that.

Now my problem….

It seems twitter is quite picky in what they think is an url:
I got the most basic ones (starting with http(s):// and such), but twitter also replaces some tld’s very easily, (www.)google.com [whatever].net/.biz/.info are just a few of them)
but not .nl .de .tk

Now I was wondering if perhaps someone has found out which ones they do and which ones they don’t ‘shorten’.

now because I’m pretty sure my regex isn’t the best either I’ll drop that here as well:

((http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)|([\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)
  • 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-03T11:41:33+00:00Added an answer on June 3, 2026 at 11:41 am

    I figured it out, I found a pretty important line on the tld wikipage. It states that all country TLD’s are two chars long. And also the other way around; all 2 char tld’s are countries. With that in mind, I started testing a bunch of them with twitter and I’m pretty sure I now know what url’s twitter shortens and which ones they don’t.

    • All url’s starting with http:// or https://
    • All url’s like [something].[non country tld] # .com .biz .mobi etc. (Except .arpa & .aero)
    • All url’s like [something].[something].[valid tld] # including countries

    • links like http://[user]:[pass]@[something].[tld] will NOT be shortened

    Now to build a regex for it, i’ll post it here as soon as I think I have it 😀

    this is what I got this far:

    /(^(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?:(?:[-\w]+\.)+(?:com|asia|cat|coop|edu|int|tel|pro|org|net|gov|mil|biz|info|mobi|name|jobs|museum|travel|([a-z]{2})))(?::[\d]{1,5})?(?:(?:(?:\/(?:[-\w~!$+|.,=\(\)]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?)/gim;
    

    one major flaw still in it, it also accepts [domain].[tld] which twitter doesn’t.

    I hope this will help someone in the future. I’m pretty sure there’s not a whole lot easy-to-find info about this on the web (or at least I couldn’t find it).

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

Sidebar

Related Questions

My main question is given a feature centroid, how can I draw it in
Here's the main question I guess : Is there a .NET way to get
Newb question. How can you know what the main launch Activity is? Learning Android.
Main question is what are the implications of allowing the this keyword to be
My main question is : Is there a good practice to serve binary files
The title is the main question. The exact scenario (I am 'using namespace std;'):
This was the main question posed by Greg Wilson's bits of evidence presentation. I'm
first of all, my main question: What are some good troubleshooting techniques when you
I am using Struts2, Spring 2 and Junit 4.5. My main question is, whether
Quick question, is there a way to call your main method whatever you like

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.