How can I loop over the lines in a text file

Comments

1 comment

  • Avatar
    jesus

    Hi daveb42,

    You could use the below code that iterates between the lines and saves each of them in a variable:

     <readFile>
           <name>text</name>
           <path>${file}</path>
     </readFile>
    
     <while>
        <actionList>
          <setInstallerVariableFromRegEx name="line" pattern="^([^\n]*)(\n|$).*" substitution="\1" text="${text}"/>
          <setInstallerVariableFromRegEx name="text" pattern="^[^\n]*(\n|$)(.*)" substitution="\2" text="${text}"/>
    
          <!-- Actions to be executed. The line variable have the content of the currently line -->
          ...
    
         </actionList>
         <conditionRuleList>
            <regExMatch text="${text}" logic="matches" pattern="[^\n]+.*(\n|$)"/>
         </conditionRuleList>
     </while>
    
    0
    Comment actions Permalink

Please sign in to leave a comment.