Closed WojciechRynczuk closed 7 years ago
I wonder why non-capturing group didn't work (?: +.*)?
while the capturing group is working ( +.*)?
.
Why do you need any group at all?
After more thinking: this won't work.
We need to match someting e
or something e comment
, space should not be required after e
if no comment is desired. So the regex need to match either e<newline>
or e comment<newline>
. This is rather hard to do now because newline matching is added in another place.
Please see: https://regex101.com/r/ZWMQsg/2
This is why I used the group. It works. It is matching e<newline>
or e comment<newline>
. It also fails to match something esomething<newline>
as the required space between e
and the comment is missing.
So from the lines below:
#12 F.Val ecomment
#10 C.Val e
#12 F.Val ee comment
#14 G.Val e More comments
Only lines:
#10 C.Val e
#14 G.Val e More comments
were matched correctly.
I was just wondering why the non-capturing group failed to work while a capturing group works for the same regex. It seemed to me that the matching behavior shall be the same but obviously it isn't.
Ok I forgot that we also match line beginning. So it's ok then.
The solution has been tested and it works properly for different EOLs for Windows and Linux. I decided not to indicate in the user manual any specific EOL which is supported as both of them are OK now. A test is missing. As our github repository is stored in the Linux format one would have to prepare a script to manipulate input files on-the-fly.