Split string and run "File Contents iterator" on a variable?

 

I have FinalBuilder 6
 
Let's say I have a text file looks like this:
Test1234__555
TEST9955__843
What I want to do is to go over each line of the file (using File Contents iterator ) but after the __ and everything after it was chopped from each line
What is the best way to do that ? Do I have to use Text find \ replace and write the new lines to a new text file ?
 

Hi Elad,

No, it's not necessary to write out a new file. I've attached an example project which uses Text Find / Replace as the child of the File Contents Iterator, to strip the suffix from each line as it goes.

As written, the project maintains two variables, FullName and Prefix. If you only need access to the Prefix section of each line, you could remove the FullName variable and the Set Variable action from the project, and have the File Contents Iterator set the Prefix variable directly. This should make more sense after you've taken a look at the project. :)

Please let us know how you go.

Regards,

Angus

splitfilecontents.zip (2.311 KB)

Thanks, that is exactly what I wanted, Now I have another question
Let's say I have a VS 2005 vcproj file, I need to get a list of all project confoguration and paltform meaning I want to get a list like this
Debug|Win32
Release|x64
Debug|Any CPU
Is there a way I can extract this info using FinalBuilder action or I have to do it myself using a script ?

Also

If I have this path \\PCNAME\DIR1\DIR2 how can I use Path Manipulation action to extract only the PCNAME?

Hi Elad,

There's nothing built-in to FinalBuilder to extract information from the .vcproj, but it's an XML file so you should be able to use something like an XML Node Iterator with the XPath set to //Configurations/Configuration and the Attribute set to "Name", to iterate over all of the configurations defined in the project.

Bear in mind that you'll need to set a default namespace on the XML actions, as explained here: https://www.finalbuilder.com/blogs.aspx?EntryId=247

For the path manipulation problem, I don’t think we have a built-in action to do this.

You can use the Text Find / Replace action configured as follows:

“Find String” tab:

“Search in variable contents”
Search string: \\(\w+)\
“Match as regular expression”


“Replace” tab:

“Replace text and write back to variable”
Replacement String: $1
“Substitute regular expression matches…”

Regards,

Angus