aspose file tools*
The moose likes Java in General and the fly likes Help with Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with Regex" Watch "Help with Regex" New topic
Author

Help with Regex

Jordan Smith
Ranch Hand

Joined: Apr 06, 2008
Posts: 89


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

Joined: Feb 25, 2006
Posts: 266


(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

Joined: Apr 06, 2008
Posts: 89
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

Joined: Feb 25, 2006
Posts: 266
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

Joined: Apr 06, 2008
Posts: 89
you are right.
it works perfect - i didn't clear the cache.
Thanks alot!!
Piet Verdriet
Ranch Hand

Joined: Feb 25, 2006
Posts: 266
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
 
subject: Help with Regex