{"id":157,"date":"2016-12-08T01:14:07","date_gmt":"2016-12-08T01:14:07","guid":{"rendered":"http:\/\/python.wp.w3.pt\/?p=157"},"modified":"2016-12-08T18:09:11","modified_gmt":"2016-12-08T18:09:11","slug":"expressoes-regulares-ii","status":"publish","type":"post","link":"http:\/\/python.w3.pt\/?p=157","title":{"rendered":"Express\u00f5es regulares II"},"content":{"rendered":"<p>Aparentemente, para encontrar hashtags num texto, mesmo que os carateres do texto estejam em Unicode, e considerando apenas carateres de texto, excluindo separadores como os espa\u00e7os, sinais de pontua\u00e7\u00e3o, etc., podemos usar o c\u00f3digo do exemplo seguinte:<\/p>\n<pre>#!\/usr\/bin\/python\r\n# -*- coding: utf-8 -*-\r\nfrom __future__ import unicode_literals\r\nimport re\r\nimport collections\r\nline = \"#fbf to me in Edinburgh, #fbf Scotland back #a\u00e7o in November 2007. #c\u00e3o #brexit #c\u00e9u Most of you will be too young to remember #this, #brexit #brexit #brexit but back then, the entire UK was part of the European Union. History is fascinating.\"\r\n\r\np = re.compile(ur'(?i)(?&lt;=\\#)\\w+',re.U)\r\nr = p.findall(line)\r\nprint r\r\n<\/pre>\n<p>O resultado \u00e9:<\/p>\n<pre>[u'fbf', u'fbf', u'a\\xe7o', u'c\\xe3o', u'brexit', u'c\\xe9u', u'this', u'brexit', u'brexit', u'brexit']\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Aparentemente, para encontrar hashtags num texto, mesmo que os carateres do texto estejam em Unicode, e considerando apenas carateres de texto, excluindo separadores como os espa\u00e7os, sinais de pontua\u00e7\u00e3o, etc., podemos usar o c\u00f3digo do exemplo seguinte: #!\/usr\/bin\/python # -*- coding: utf-8 -*- from __future__ import unicode_literals import re import collections line = &#8220;#fbf to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/python.w3.pt\/?p=157\" class=\"more-link\">Continuar a ler <span class=\"screen-reader-text\">&#8220;Express\u00f5es regulares II&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/157"}],"collection":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157"}],"version-history":[{"count":4,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":167,"href":"http:\/\/python.w3.pt\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions\/167"}],"wp:attachment":[{"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/python.w3.pt\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}