{"id":3479,"date":"2010-09-16T13:14:00","date_gmt":"2010-09-16T13:14:00","guid":{"rendered":""},"modified":"2026-04-18T22:53:17","modified_gmt":"2026-04-18T22:53:17","slug":"splitting-text-using-python","status":"publish","type":"post","link":"https:\/\/hellem.org\/wblog\/?p=3479","title":{"rendered":"Splitting text using Python"},"content":{"rendered":"<p>Created a script just to test how to split text using Python. First I have to split on the delimiter &#8216;__&#8217;, then on the &#8216;.&#8217;. <\/p>\n<p><!-- codeblock lang=\"\" line=\"1\" --><\/p>\n<pre><code>#!\/usr\/bin\/python\r\npropertyFilename=\"commons-ear__R01_INC_002.properties\"\r\nprint propertyFilename\r\nversionWithFileExt = propertyFilename.split('__')\r\nprint versionWithFileExt\r\nversion = versionWithFileExt[1].split('.')\r\nprint version\r\n#And to get the final string\r\nprint version[0]\r\n<\/code><\/pre>\n<p><!-- \/codeblock --><\/p>\n<p>Not that hard, but what confused me when reading the Python documentation was that str.split() is deprecated. But as it turned out, that is in version 2.7, currently we are using 2.4, find out by issuing the command<br \/>\n<code>ls -l \/usr\/bin\/python*<br \/>\n<\/code><\/p>\n<p>From version 2.7 you should instead use stringObject.rpartition(sep), see more at <a href=\"http:\/\/python.about.com\/od\/pythonstandardlibrary\/a\/string-methods_2.htm\">about.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Created a script just to test how to split text using Python. First I have to split on the delimiter &#8216;__&#8217;, then on the &#8216;.&#8217;. #!\/usr\/bin\/python propertyFilename=&#8221;commons-ear__R01_INC_002.properties&#8221; print propertyFilename versionWithFileExt = propertyFilename.split(&#8216;__&#8217;) print versionWithFileExt version = versionWithFileExt[1].split(&#8216;.&#8217;) print version #And to get the final string print version[0] Not that hard, but what confused me when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-3479","post","type-post","status-publish","format-standard","hentry","category-work-geek"],"_links":{"self":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3479"}],"version-history":[{"count":1,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3479\/revisions"}],"predecessor-version":[{"id":14124,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3479\/revisions\/14124"}],"wp:attachment":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}