텍스트에서 URL을 가져 오는 방법은 무엇입니까? 예를 들어텍스트에서 URL을 가져 오는 방법
: 나는 URL을 얻고 다른 변수로 설정해야
string Text = "this is text with url http://test.com";
. 어떻게하면 ASP.NET에서이 작업을 수행 할 수 있습니까?
텍스트에서 URL을 가져 오는 방법은 무엇입니까? 예를 들어텍스트에서 URL을 가져 오는 방법
: 나는 URL을 얻고 다른 변수로 설정해야
string Text = "this is text with url http://test.com";
. 어떻게하면 ASP.NET에서이 작업을 수행 할 수 있습니까?
, 당신은뿐만 아니라이 작업을 수행 할 수 있습니다
string text = "this is text with url http://test.com";
Match match = Regex.Match(text, @"http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$");
// gets you http://test.com
string url = match.Value;
reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
텍스트에서 URL을 찾는 정규식입니다.
호프가 도움이 되길 바랍니다. . // [. A-ZA-Z0-9-] + [A-Za-z]와 {: \ (FTPS | HTTPS | | FTP HTTP)
string _Url = "this is text with url http://test.com";
MatchCollection _Match = Regex.Matches(_Url , @"http.+)([\s]|$)");
string _Address= _Match[0].Value.ToString();
U는
"/를 사용할 수 있습니다 2,3} (/ \ S *)/"검색을위한 정규 표현식으로
... ;?)
사항 String.split 메서드 (String [] StringSplitOptions)
http://msdn.microsoft.com/en-us/library/tabh47cf.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
당신은 예를 찾을 수 있습니다 : C#을 - C++ - F # - VB
[ComVisibleAttribute (거짓)]
공공 문자열 [] 분할을 (
문자열 [] 분리,
StringSplitOptions 옵션
)
이 경우 "http : //"는 구분 기호로 사용할 수 있습니다. 이전 답변에 추가
string url = Text.Substring(Text.IndexOf("http://"));
는 정규식 패턴 – PiLHA
http://stackoverflow.com/questions/5218863/find-url-in-plain를 사용하여 -text-and-insert-html-a-markups는 약간의 연구를합니다. – Liviu