I have text stored in a database and I want to filtered the urls that the text contain. How is it possible to filter the urls from text using Java code. For example I have the following text inside my db "The dress-a-likes! Try to look normal and this is what happens. @ Bar Louie http://t.co/sNVcoqT0Bc"
. How can I filtered the link http://t.co/sNVcoqT0Bc.
Pattern p = Pattern.compile("http://.*|www\\..*");
DBCursor cursor = coll.find(query);
while(cursor.hasNext()) {
System.out.println(cursor.next().get("text"));
Matcher m = p.matcher("http://...");
}
How can I filtered the cursor.next().get("text") with the matcher. Cursor... is an object while matcher waiting for a String. How can I convert that object to String?