This project has moved and is read-only. For the latest updates, please go here.


Excluding chars in regex works in GUI but not in command-line



First of all thank you for developing and supporting this program which is very useful and well documented !

I'm having an issue though while using a complex regex, especially when I'm using this kind of expression : [^\"] (any character which is not ")

The " is escaped because it is inside a quoted string in the command line, I tried with other non-escaped characters and it doesn't work either.

It is actually working like a charm in the GUI, so I suppose this kind of expression is not interpreted the same way.


ericpopivker wrote Mar 3, 2014 at 12:49 PM


This issue should be fixed in 1.5.1 BETA:

Please give it a try and let me know if it doesn't work.


clechasseur wrote May 22, 2014 at 2:23 AM

Looks like the issue, or another similar to it, still exists in 1.6.

I created a text file with the following content:


I called it this way through the command-line:

fnr.exe --cl --find "^\"[^e]*" --replace "WHOA" --useRegEx ...

clechasseur wrote May 22, 2014 at 2:25 AM

(Sorry, force of habit, hit Ctrl-S and it submitted)

The end result in the file:


It looks like the [^e]* didn't match anything.

I tried using the same regex in the UI:


...and the result was correct this time:


ericpopivker wrote May 22, 2014 at 8:26 AM

aRandomName wrote Jun 21, 2016 at 10:34 PM

Thank you for providing a very useful tool!

Like the OP, I also ran into difficulties in writing regex's for the command line, which involved excluding double-quotes from the match, e.g., [^"]. After experimenting, the problems appear to be due to "escape hell", and not bugs in fnr.exe. I'm posting what I found, should others run into these problems.

Below are two fnr.exe test cases. For the regex, characters which are not a double-quote are replaced by #.
Both test cases are run from a cmd.exe window, in Windows 7.
Note the fnr.exe parameters are the same, except in the second test-case, there is an extra ^, within the [ ]. I think the extra ^ is needed because when the cmd.exe command is used, ^ is treated as an escape character, so ^^ results in ^.
C:\$jim\fnr.exe --cl --dir "c:\$jim" --fileMask "ztest.txt" --useRegEx --find "[^""]" --replace "#"

cmd.exe /K " "C:\$jim\fnr.exe" --cl --dir "c:\$jim" --fileMask "ztest.txt" --useRegEx --find "[^^""]" --replace "#" "
I also ran that same regex via VBA, using a command-shell:
Set wsh = VBA.CreateObject("WScript.Shell")
wsh.Run(cmdString, windowStyle, waitOnReturn)
The contents of the VBA variable cmdString is below. The contents are what's between the single quotes, but not including the single quotes.
Note cmd.exe was used, but only one ^ was needed.

'cmd.exe /K " "C:\$jim\fnr.exe" --cl --dir "C:\$jim" --fileMask "ztest.txt" --useRegEx --find "[^""]" --replace "#" "'