Jump to content

Find URI in text: Difference between revisions

m (→‎{{header|jq}}: documentation)
Line 229:
ftp://domain.name/path/embedded?punct/uation.
ftp://domain.name/dangling_close_paren)</lang>
 
=={{header|Objeck}}==
Used a regex instead of writing a parser.
<lang objeck>
use RegEx;
 
class FindUri {
function : Main(args : String[]) ~ Nil {
text := "this URI contains an illegal character, parentheses and a misplaced full stop:
http://en.wikipedia.org/wiki/Erich_Kästner_(camera_designer). (which is handled by http://mediawiki.org/).
and another one just to confuse the parser: http://en.wikipedia.org/wiki/-)
\")\" is handled the wrong way by the mediawiki parser.
ftp://domain.name/path(balanced_brackets)/foo.html
ftp://domain.name/path(balanced_brackets)/ending.in.dot.
ftp://domain.name/path(unbalanced_brackets/ending.in.dot.
leading junk ftp://domain.name/path/embedded?punct/uation.
leading junk ftp://domain.name/dangling_close_paren)
if you have other interesting URIs for testing, please add them here:";
 
found := RegEx->New("\\w*://(\\w|\\(|\\)|/|,|;|'|\\?|\\.)*")->Find(text);
count := found->Size();
"Found: {$count}"->PrintLine();
each(i : found) {
found->Get(i)->As(String)->PrintLine();
};
}
}</lang>
 
<pre>
Count: 8
http://en.wikipedia.org/wiki/Erich_K
http://mediawiki.org/).
http://en.wikipedia.org/wiki/
ftp://domain.name/path(balanced_brackets)/foo.html
ftp://domain.name/path(balanced_brackets)/ending.in.dot.
ftp://domain.name/path(unbalanced_brackets/ending.in.dot.
ftp://domain.name/path/embedded?punct/uation.
ftp://domain.name/dangling_close_paren)
</pre>
 
=={{header|Perl 6}}==
760

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.