Hi community,
I might have an easy questions regarding handling regex matches.
I have a document (loaded with the document operator), and now I want to use a regex to retrieve a certain part of the document. My regex code got e.g. three matches. So when running rapidminer, all three matches will be shown together (appended/joined together). So my questions is, if there is a way to loop through all regex matches like I can do it in Java or Python ?
For example like:
<SPAN class="kwd">import</SPAN><SPAN class="pln"> re
s </SPAN><SPAN class="pun">=</SPAN> <SPAN class="str">"ABC12DEF3G56HIJ7"</SPAN><SPAN class="pln">
pattern </SPAN><SPAN class="pun">=</SPAN><SPAN class="pln"> re</SPAN><SPAN class="pun">.</SPAN><SPAN class="pln">compile</SPAN><SPAN class="pun">(</SPAN><SPAN class="pln">r</SPAN><SPAN class="str">'([A-Z]+)([0-9]+)'</SPAN><SPAN class="pun">)</SPAN>
<SPAN class="kwd">for</SPAN> <SPAN class="pun">(</SPAN><SPAN class="pln">letters</SPAN><SPAN class="pun">,</SPAN><SPAN class="pln"> numbers</SPAN><SPAN class="pun">)</SPAN> <SPAN class="kwd">in</SPAN><SPAN class="pln"> re</SPAN><SPAN class="pun">.</SPAN><SPAN class="pln">findall</SPAN><SPAN class="pun">(</SPAN><SPAN class="pln">pattern</SPAN><SPAN class="pun">,</SPAN><SPAN class="pln"> s</SPAN><SPAN class="pun">):</SPAN>
<SPAN class="kwd">pass # do anything</SPAN>
This is just a sample code, and not my specific task. I just want to know how to loop through regex matches.
I hope my question is quite clear :-)
Best regards,
Markus