Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Replace URL

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I've a string with so many urls like "This string causes trouble http://www.abc.com and this also https://www.abc.com and this also www.xyz.com. Ive to display it as links in the page.How do i do that? Any inbuilt functions to do this?
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use a <href =...> e.g.
... causes trouble <a href="http://www.abc.com">http://www.abc.com</a>; and ...
hope this helps.
[ January 22, 2003: Message edited by: boyet silverio ]
 
Devutty Pradeep
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I mean like this
String a = "This string causes trouble http://www.abc.com and this also https://www.abc.com and this also www.xyz.com.";
Ive to change it to
String b = "This string causes trouble <a href="http://www.abc.com">http://www.abc.com</a>; and this also <a href="https://www.abc.com ">https://www.abc.com</a>; and this also <a href="www.xyz.com">www.xyz.com</a>.
Any idea?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you want to recognize certain patterns in a string and translate them to other patterns? This sounds like a job for java.util.regex !
First you will need to think about what distinguishes one of these patterns. How do you, as a reader, recognize them? Once you understand this, you can write it as a "regular expresion". The java.util.regex API has tools for doing just this sort of transformation.
 
He's giving us the slip! Quick! Grab this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic