mashiina Posted March 17, 2014 Report Share Posted March 17, 2014 (edited) Sveiki. Vai kāds nevarētu padalīties ar gatavu regex, kurā uztaisītu aktīvu linku pēc maniem piemēriem. Piemēram:https://gist.github.com/anonymous/9602994Atgriežhttp://www.google.lv/ Bet vēlētos arī, lai strādā šādā veidā: ftp://www.web.com => web.com web.net => web.net www.website.info => website.info website.us => website.us web.ws?query=true => web.ws www.web.biz/?query=true => web.biz ftp://web.in?query=true => web.in media.google.com => media.google.com ns.google.pk => ns.google.pk www3.smart.br/?test => www3.smart.br w1.smart.so => w1.smart.so http://website.info/?ques==two&t=p => website.info https://www.weborwebsite.com => weborwebsite.com Kāds ar vienu regex var šo uzrakstīt? Edited March 17, 2014 by mashiina Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 17, 2014 Report Share Posted March 17, 2014 https://github.com/jsocol/bleach/blob/master/bleach/__init__.py#L64 Quote Link to comment Share on other sites More sharing options...
Kavacky Posted March 18, 2014 Report Share Posted March 18, 2014 Saraksts ar TLD - epic sviests, lol. Kāpēc kaut kas tāds jādara? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 18, 2014 Report Share Posted March 18, 2014 (edited) Ok, uzrakstīju tev šito regex.... lai ātrāk pamostos. :D Should match 99% cases. http://regex101.com/r/mL8qO9 Vari palaist caur http://regex101.com/ un patestēt. Tur apakšā ir tāda lieta kā “Expression explained“, kas arī var diezgan palīdzēt. You're welcome. P.S. Šitas nematchos pilnos linkus kā piemēram foo.bar/path/to/page. Edited March 18, 2014 by daGrevis Quote Link to comment Share on other sites More sharing options...
gurkjis Posted March 18, 2014 Report Share Posted March 18, 2014 Saraksts ar TLD - epic sviests, lol. Kāpēc kaut kas tāds jādara? Nu tur nav nekādu citu variantu, kā plaintextā nomatchot patternu "domens.tld" - tas ir - 2 teksta segmenti, kur pa vidu ir punkts , jo arī parastā tekstā šādi patterni var gadīties, kas reali nav domāti domēni. Tāpēc vajag TLD sarakstu, lai vismaz zināmos TLD šādi nomatchotu. Quote Link to comment Share on other sites More sharing options...
indoom Posted March 18, 2014 Report Share Posted March 18, 2014 http://regex101.com/r/wI2mK3 darbosies uz visiem gadījumiem, izņemot github.com atgriezīs google.lv Quote Link to comment Share on other sites More sharing options...
Kavacky Posted March 24, 2014 Report Share Posted March 24, 2014 Nu tur nav nekādu citu variantu, kā plaintextā nomatchot patternu "domens.tld" - tas ir - 2 teksta segmenti, kur pa vidu ir punkts , jo arī parastā tekstā šādi patterni var gadīties, kas reali nav domāti domēni. Tāpēc vajag TLD sarakstu, lai vismaz zināmos TLD šādi nomatchotu. Parastā tekstā šādi patterni nevar gadīties, jo nav jāizdabā katram analfabētam, kurš pēc punkta nemāk iesist space. Uzturēt tādu sarakstu ir nevis vienkārši bedzjēdzīgi, bet arī pilnīgi stulbi, jo tagad jauni TLD rodas kā sēnes pēc lietus. Ja ir kaut nedaudz saprāta, negribēsies veikt lieku darbu un katru dienu pārskatīt, vai nav jauns TLD uzradies. Quote Link to comment Share on other sites More sharing options...
gurkjis Posted March 24, 2014 Report Share Posted March 24, 2014 Tas gan tiesa - par to, ka rodas arvien jauni TLD. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 25, 2014 Report Share Posted March 25, 2014 README.md, foobar.txt. Quote Link to comment Share on other sites More sharing options...
e-remit Posted March 25, 2014 Report Share Posted March 25, 2014 Kāpēc jāuztur saraksts, ja var pārbaudīt ar checkdnsrr()? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted March 25, 2014 Report Share Posted March 25, 2014 Kāpēc jāsarežģī sev dzīvi ar nevajadzīgu pārbaudi? Quote Link to comment Share on other sites More sharing options...
Lauris Posted March 25, 2014 Report Share Posted March 25, 2014 (edited) README.md, foobar.txt. http://readme.md/ [0] [0] - http://en.wikipedia.org/wiki/.md Edited March 25, 2014 by Lauris Quote Link to comment Share on other sites More sharing options...
marrtins Posted March 25, 2014 Report Share Posted March 25, 2014 Vnk vajag parsēt tikai to, kas ar protokolu priekšā. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 25, 2014 Report Share Posted March 25, 2014 > Vnk vajag parsēt tikai to, kas ar protokolu priekšā. Nop. example.com, bez protokola, ir valīds links un to vajag pārvērst par http://example.com. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 25, 2014 Report Share Posted March 25, 2014 > http://regex101.com/r/mL8qO9 Or GTFO! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.