File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Regex

 
Jordan Smith
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi

I would my regular expression to convert URL to click here + a href.

I have the following regular expression:



But in case that the user enters a URL with comma or period in the end, it converts it with the comma.

for example:

"go to http://jpost.com, and have fun"

will be go to click here

but the comma shouldn't be included in the href!

how can i write the regular expression so if there is comma/period + space, it would ignore it?

Thanks!
 
Piet Verdriet
Ranch Hand
Posts: 266
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


(The forum software "eats" the anchor tags, so add "href=" in front of "\"$0\"")

Note that the solution above will only accept urls that end with a letter. Expand it as you see fit.
 
Jordan Smith
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
it's not working with URL that have , in them.
like:
http://www.ynetnews.com/articles/0,7340,L-3670012,00.html

how can i enable in the regex comma or minus only if it comes with out space after the charachter?

Thanks!
 
Piet Verdriet
Ranch Hand
Posts: 266
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
odelya yomtov-glick wrote:Hi!
it's not working with URL that have , in them.
like:
http://www.ynetnews.com/articles/0,7340,L-3670012,00.html
...


It works fine with me.
 
Jordan Smith
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right.
it works perfect - i didn't clear the cache.
Thanks alot!!
 
Piet Verdriet
Ranch Hand
Posts: 266
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
odelya yomtov-glick wrote:you are right.
it works perfect - i didn't clear the cache.
Thanks alot!!


No problem.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic