Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edited answer:</p> <pre><code>&gt;&gt;&gt; s = r'"&lt;pd:link scheme="http://www.w3.org/1999/xhtml" target="www.altruvest.org &lt;pd:unicode ch="2014"/&gt; or &lt;pd:unicode ch="2014"/&gt; www.Boardmatch.org"&gt;www.altruvest.org &lt;pd:unicode ch="2014"/&gt; or &lt;pd:unicode ch="2014"/&gt; www.Boardmatch.org&lt;/pd:link&gt;"' &gt;&gt;&gt; import re &gt;&gt;&gt; r = re.search(r'=".*?(&lt;pd:unicode ch="\d+"/&gt;).*?"', s, re.DOTALL) &gt;&gt;&gt; r.groups() ('&lt;pd:unicode ch="2014"/&gt;',) </code></pre> <p>What the above does is to match the <code>pd:unicode</code> tags when they are preceded by a <code>="</code> and followed by <code>"</code>. The <code>re.DOTALL</code> ignores newlines (treats them as normal characters).</p> <p>Bare in mind that what you are asking to do is <em>parsing</em> XML, something for which you should use an xmlparser (see for example <a href="http://docs.python.org/library/xml.etree.elementtree.html" rel="nofollow noreferrer">xml.etree</a> or a more general discussion <a href="http://wiki.python.org/moin/PythonXml" rel="nofollow noreferrer">here</a>), and not regular expressions. Accurately parsing XML by mean of regex is actually <a href="https://stackoverflow.com/q/6751105/146792">not possible</a>, so the above regex is likely to generate false positives or to miss some true ones.</p> <p>If you don't want to go with a full XML parser, you could consider something like <a href="http://pyparsing.wikispaces.com/" rel="nofollow noreferrer">pyparsing</a> instead.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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