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

  • Home
  • SEARCH
  • 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 7445949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:10:51+00:00 2026-05-29T12:10:51+00:00

I once built a program in php that used very specific regular expressions to

  • 0

I once built a program in php that used very specific regular expressions to match links, however that pattern doesnt seem to work in java, Im trying to find the java equivalent of

"~http://(bit.ly|t.co)~"

in php this would would match links such as http://t.co/UURRNlrK and http://bit.ly/AenG5W what would be a java equivalent of this?

  • 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-05-29T12:10:52+00:00Added an answer on May 29, 2026 at 12:10 pm

    I think you are looking for

    String str = "http://t.co/UURRNlrK";
    String p = "(http://(t\.co|bit\.ly).*)";
    
    Pattern pattern = Pattern.compile(p);
    Matcher matcher = pattern.matcher(str);
    
    if(matcher.find())
    System.out.println(matcher.group(0));
    

    Output = http://t.co/UURRNlrK

    if str = "http://bit.ly/AenG5W"

    Output = http://bit.ly/AenG5W

    Here is a nice Regex Tutorial for java.

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

Sidebar

Related Questions

I have an program that gets installed via an msi. The msi was built
I am trying to build a program that, once the button was click, every
Once the program is built, where on the hard drive is it? Does Xcode
Once again one of those: Is there an easier built-in way of doing things
Once again a very beginner-ish question, but here I go: I would like to
I have a core dump of an executable that was NOT built with debug
I have an NSIS installer script that I'm using to deploy a py2exe-built app
I tried to package a Twisted program with py2exe, but once I run the
I have a service application built in Delphi that works great. It does exactly
I have a legacy VB6 application that was built using MSDE. As many client's

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.