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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:25:09+00:00 2026-06-12T13:25:09+00:00

I need to find short url in the text post in java. I have

  • 0

I need to find short url in the text post in java. I have the following regex expression
“(http://(bit\.ly|t\.co|lnkd\.in|tcrn\.ch).*?)\s”

I have 2 questions

  1. The problem with the above expression is it doesn’t match the short
    url if it is at the end of line. ex For text “blah
    http://linkd.in/R9Msf3 blah” gives “http://linkd.in/R9Msf3 “

    But blah blah http://linkd.in/R9Msf3 does not gives
    “http://linkd.in/R9Msf3”

    Any suggestions how to match both patterns ? Basically I just need
    to replace the short url out of the text.

  2. Also is there a better way to get all the short url format? If I
    hard code it then everytime I would have to add a new format to the
    config.

  • 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-12T13:25:10+00:00Added an answer on June 12, 2026 at 1:25 pm

    Instead of .* use \S* to avoid matching whitespace. You don’t need the ? and you can use \b instead of \s to match the boundary between the end of the url and whitespace or end of string.

    (http://(bit\.ly|t\.co|lnkd\.in|tcrn\.ch)\S*)\b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text I need to find in each proposal max word and
I need to send a SOAP request to a URL. But i find this
I need to find a way to join two XML files when they have
Need some help with the following: I have several worksheets with the same structure
I have an array of phone numbers and I need to find if a
I have a string(char*), and i need to find its underlying datatype such as
Hi I have a list of people with their ages, I need to find
Need to find the timestamp for the first minute of the first day of
I need to find a flexible solution for access control in PHP. In the
i need to find out automationid for key board values? how to send keystrokes

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.