0

i want to check if a given string has a regular expression or not. I am using this

#if($feed.message.matches('.*https?://.*'))
     $feed.message <a href="$feed.message"></a>
#else   
   $feed.message
#end

so it works for following url (and i get both message and message url)

http://www.p4pune.com/img/Scene.jpeg 

but not working for following url (i get only message string)

string before url http://www.p4pune.com/img/Scene.jpeg

where feed.message contains the links (give above)

1
  • Could you be specific on the intended results? In the second case, do you really need the following? string before url http://www.p4pune.com/img/Scene.jpeg <a href="string before url http://www.p4pune.com/img/Scene.jpeg"></a> Commented Apr 17, 2013 at 12:29

1 Answer 1

1

By removing some characters of the beginning of your regex, it seems to work for me :

(http|ftp|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:/~+#-]*[\w@?^=%&amp;/~+#-])?
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.