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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:02:41+00:00 2026-06-01T22:02:41+00:00

I have a string as : This is a URL http://www.google.com/MyDoc.pdf which should be

  • 0

I have a string as : “This is a URL http://www.google.com/MyDoc.pdf which should be used”

I just need to extract the URL that is starting from http and ending at pdf :
http://www.google.com/MyDoc.pdf

String sLeftDelimiter = "http://";
String[] tempURL = sValueFromAddAtt.split(sLeftDelimiter );
String sRequiredURL = sLeftDelimiter + tempURL[1];

This gives me the output as “http://www.google.com/MyDoc.pdf which should be used”

Need help on 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-06-01T22:02:42+00:00Added an answer on June 1, 2026 at 10:02 pm

    This kind of problem is what regular expressions were made for:

    Pattern findUrl = Pattern.compile("\\bhttp.*?\\.pdf\\b");
    Matcher matcher = findUrl.matcher("This is a URL http://www.google.com/MyDoc.pdf which should be used");
    while (matcher.find()) {
      System.out.println(matcher.group());
    }
    

    The regular expression explained:

    • \b before the “http” there is a word boundary (i.e. xhttp does not match)
    • http the string “http” (be aware that this also matches “https” and “httpsomething”)
    • .*? any character (.) any number of times (*), but try to use the least amount of characters (?)
    • \.pdf the literal string “.pdf”
    • \b after the “.pdf” there is a word boundary (i.e. .pdfoo does not match)

    If you would like to match only http and https, try to use this instead of http in your string:

    • https?\: – this matches the string http, then an optional “s” (indicated by the ? after the s) and then a colon.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a url string like this: http://www.google.com/cse?cx=017840637368510444960:ny1lmky7r-0&client=google-csbe&output=xml_no_dtd&q=simon+g I need to send this url
I have the following string: Look on http://www.google.com. I need to convert it to:
if I have a url string like http://www.google.com how can I convert that to
I have an url like this: http://www.w3schools.com/PHP/func_string_str_split.asp I want to split that url to
I have a very basic AJAX function in JQuery: $.ajax({ url: http://www.google.com, dataType: html,
I have a URL like: http://www.google.com/test.html?d=1232&u=32 and I want to add it as a
I have textview which contains urls like www.google.com . for this textview a have
I have the following so far: ^((http[s]?|ftp):\/\/)(([^.:\/\s]*)[\.]([^:\/\s]+))(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)?$ Been testing against these: https://www.google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com.ar:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash https://google.com:8080/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash
I have a YQL output JSON string at this URL: YQL JSON I found
I have this string in PHP: $string = name=Shake & Bake&difficulty=easy; For which I

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.