linkify

C# code to linkify urls in a string

别说谁变了你拦得住时间么 提交于 2019-11-26 08:08:29
问题 Does anyone have any good c# code (and regular expressions) that will parse a string and \"linkify\" any urls that may be in the string? 回答1: It's a pretty simple task you can acheive it with Regex and a ready-to-go regular expression from: http://regexlib.com/ Something like: var html = Regex.Replace(html, @"^(http|https|ftp)\://[a-zA-Z0-9\-\.]+" + "\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?" + "([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$", "<a href=\"$1\">$1</a>"); You may also be interested not only in

Android: Linkify TextView

只谈情不闲聊 提交于 2019-11-26 04:27:56
问题 I have textview which I need to linkify. Here\'s what I am doing.. TextView text = (TextView) view.findViewById(R.id.name); text.setText(\"Android...Update from Android\"); Pattern pattern = Pattern.compile(\"Android\"); String scheme = \"www.android.com\"; Linkify.addLinks(text, pattern, scheme); The text-view is displayed correctly with the text \"Android...Update from Android\", but I am facing two problems. 1) My text string has two instances of the string \"Android\". So, both the text