Note that there are some explanatory texts on larger screens.

plurals
  1. POPython regular expression for r.findall
    primarykey
    data
    text
    <p>I am using findall to separate text. </p> <p>I started with this expression re.findall(r'(.<em>?)(\$.</em>?\$)' but it doesn't give me the data after the last piece of text found. I missed the '6\n\n' </p> <p>How do I get the last piece of text?</p> <p>Here is my python code:</p> <pre><code>#!/usr/bin/env python import re allData = ''' 1 2 3 here Some text in here $file1.txt$ 4 Some text in here and more $file2.txt$ 5 Some text $file3.txt$ here $file3.txt$ 6 ''' for record in re.findall(r'(.*?)(\$.*?\$)|(.*?$)',allData,flags=re.DOTALL) : print repr(record) </code></pre> <p>The output I get for this is:</p> <pre><code>('\n1\n2\n3 here Some text in here \n', '$file1.txt$', '') ('\n4 Some text in here and more ', '$file2.txt$', '') ('\n5 Some text ', '$file3.txt$', '') (' here \n', '$file3.txt$', '') ('', '', '\n6\n') ('', '', '') ('', '', '') </code></pre> <p>I really would like this output:</p> <pre><code>('\n1\n2\n3 here Some text in here \n', '$file1.txt$') ('\n4 Some text in here and more ', '$file2.txt$') ('\n5 Some text ', '$file3.txt$') (' here \n', '$file3.txt$') ('\n6\n', '', ) </code></pre> <hr> <p>Background info in case you need to see the larger picture.</p> <p>I case your are interested, I'm re-writing this in python. I have the rest of the code under control. I am just getting too much stuff out of findall.</p> <p><a href="https://discussions.apple.com/message/21202021#21202021" rel="nofollow">https://discussions.apple.com/message/21202021#21202021</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload