How to divide a string into several results with RegEx?
#1
Hello again ;=)

from the website I only get a list of genres for a movie, which need to be divided. HTML source is as following:
Code:
<div class="info">
<h5>Genre:</h5>
<div class="info-content">
Action | Abenteuer | Fantasy | Sci-Fi
</div>
</div>
With the RegEx
Code:
<RegExp input="$$1" output="&lt;genre&gt;\1&lt;/genre&gt;&lt;genre&gt;\2&lt;/genre&gt;&lt;genre&gt;\3&lt;/genre&gt;&lt;genre&gt;\4&lt;/genre&gt;" dest="5+">
    <expression>Genre:&lt;/h5&gt;\n&lt;div class="info-content"&gt;\n([^|\n]+)[ \| ]?([^|\n]*)[ \| ]?([^|\n]*)[ \| ]?([^|\n]*)</expression>
</RegExp>
I get all the four genres. But what about movies with just one, two, three genre? I will get (min) one empty genre :=(
Any chance to surpress this fault?

Regards,

Eisbahn
Reply
#2
Code:
<RegExp input="$$1" output="\1" dest="6">
    <expression noclean="1">Genre:&lt;/h5&gt;\n&lt;div class=&quot;info-content&quot;&gt;([^&lt;]*)&lt;/div&gt;</expression>
</RegExp>
<RegExp input="$$6" output="&lt;genre&gt;\1&lt;/genre&gt;" dest="5+">
  <expression repeat="yes" trim="1">([^|]*)|?</expression>
</RegExp>
Reply

Logout Mark Read Team Forum Stats Members Help
How to divide a string into several results with RegEx?0