PDA

View Full Version : Read File step - regex question


kodakdave
04-20-2010, 07:56 AM
I'd love to see an example of Read File using a regex with a non-capturing group. My step is matching the lines correctly, but even non-capturing groups are captured when I choose "Include all matches":

<step action='Read File'>
<AllMatches type='11'>-1</AllMatches>
<FailNoMatch type='11'>-1</FailNoMatch>
<FileIn>%FOLDER%\p4changes.txt</FileIn>
<Find>(?:Change )([[0-9)]]+)</Find>
<Log type='11'>-1</Log>
<Macro>LIST</Macro>
<Match type='3'>1</Match>
<NoModS type='11'>-1</NoModS>
<indent type='3'>3</indent>
<name>Read File</name>
</step>

I get result of:

Change 106
Change 105
etc.

but I need result of:

106
105
etc.

kinook
04-20-2010, 10:32 AM
You can use negative lookahead to skip text. See the attached sample.

kodakdave
04-20-2010, 11:15 AM
That did not work. Many other numbers besides the one "right after" the word "Change " also are captured now. Not sure what negative lookahead is supposed to accomplish.

By offering a workaround, and because non-captured grouping appears to work correctly in the "one match" case, I guess this is just a bug?

kodakdave
04-20-2010, 11:35 AM
truly unfortunate. If this non-capturing group would work on "all matches" in the file instead of only the first one, I would not have to write all kinds of tedious code to compensate. oh well....

kinook
04-20-2010, 12:00 PM
Including of non-capturing groups appears to be an issue with the regex library being used (or a problem in the way we're calling it), which we will investigate -- please provide a sample of the input string/file you are using.

In this case, could you just remove the 'Change ' prefix while processing the loop values (i.e., [Split("%LOOP_VALUE%")(1)])?

kinook
04-20-2010, 03:07 PM
This is fixed in the latest download (VisBuildAct.dll version 7.5.1.2 in Help | About | Install Info).

kodakdave
04-20-2010, 03:31 PM
can't wait to try it!! THANKS

kodakdave
04-21-2010, 08:56 AM
Happy to report that this behaves as it should now. great service from Kinook! Thanks all.....