Geany "Find in files" breaks when brackets included in search string - regex

I have Geany 1.27 installed in my UbuntuĀ 14.04 (Trusty Tahr). But I also have Windows 7 OS with Geany 1.28 installed.
In both these versions of Geany, when I try to find a string into a multiple files or folder with file-type filter of "phtml" or "php", I see that when my search string includes ( or ) (for example, function new() the search fails.
Now I have a slight idea that this could be due to un-escaped bracket in string acting as part of Regex in grep command. Am I right?
How can I overcome the unescaped characters in search string when searching in Geany? In both Ubuntu and Windows Geany if the method could be different.

Ensure you properly escape your braces, as depending on options, you have set the regular expression is used for searching.
Your function search would be something like new\(\). The documentation is more detailed.

Related

Emacs recursive search/replace on Windows without Cygwin

To answer "where did I also use this identifier?" -questions, I run on macOS and the linuxes
dired-maybe-insert-subdir
dired-mark-files-regexp
followed by either of:
dired-do-find-regexp
dired-do-find-regexp-and-replace
On Windows I can get by using Emacs as my IDE without Cygwin, except for dired recursive search/replace.
Does Projectile
offer commands that will search/replace an identifier recursively without requiring Cygwin?
Does any other package make recursive search/replace possible on Windows without Cygwin?
I'm not concerned about the speed, because even after installing Cygwin, the recursive invocation of Cygwin's grep from within Emacs is painfully slow.
Update:
Recursive search/replace seems to be available in both
Helm
and
Projectile.
If true, then my question is:
Is the feature available on Windows without Cygwin?
The list of requires in my .emacs is already excessive. What is a light package that will do recursive search/replace (without Cygwin on Windows)?
Clarification:
OK. Success. [Thanks to Drew] With a .emacs containing nothing but (require 'dired+), I can search-and-replace in marked files using M-+ Q on Windows without having Cygwin installed. I'm guessing that this will also work on linux/macOS, although perhaps not quite as quickly as delegating to grep. (The "Act on ALL files [] in and UNDER this dir?" confirmation message will start to get tedious, but that's a separate question.)
For the present question one issue needs clarification. dired+ augments the built-in dired family of commands. Is there a way for it to take over ordinary dired-do-find-regexp-and-replace? That's because with the one-liner .emacs, and with a few marked files in a directory listing, I get
File not found - GREP
File not found - -I
...
File not found - NUL
File not found - ;
indicating that grep is still being invoked. How can tell dired+ "I'm on Windows and I won't install Cygwin; please take over A and Q?" (mapped by default dired-do-find-regexp and the aforementioned command).
Editorial: dired+ seems a bit overwhelming, but if it solves this one problem (eliminate the need for Cygwin on Windows), it will be well-worth figuring out how to move from the usual dired commands to dired+.
I think you're looking for a way to search files and get a list of those that match a regexp. If tags-query-replace works for you on MS Windows (without Cygwin), and I think it should, then you can use command diredp-do-query-replace-regexp-recursive, bound to M-+ Q by default, available from Dired+.
That acts on all marked files in the current Dired buffer, and on all marked files in all of the buffer's marked subdirs, and so on, recursively.
With a non-negative prefix arg it acts on all files in the current buffer and all files in all subdirs, and so on, recursively. (That is, any marks are ignored, and the effect is as if everything were marked.)
If, instead of finding files that match a regexp, you want to search through files then you can use command diredp-do-isearch-regexp-recursive, bound to M-+ M-s a C-M- by default, also available from Dired+. The files to access are defined similarly (all Dired+ dired[p]-do...-recursive commands act similarly wrt which files are identified to act on). That definitely does not require any Cygwin etc. commands - it's just Isearch.

cmake source_group has no effect

I'm trying to organize a project generated for visual studio 2015 using the source_group function to add specific folders to the project, but it have no effect, here is how i do it:
set(CPP_FILES_REGEX "\\b(\\w|\\d)+\\b\\.(hpp|cpp|c|h)")
source_group("my_folder" REGULAR_EXPRESSION "${sourcers_dir}\/${CPP_FILES_REGEX}")
add_executable(my_executable ${sourcers_dir}/main.cpp ${sourcers_dir}/test.hpp)
Testes the regex here: RegExr and it works fine so the executables are being match. I also tried to add the file name but it still have no effect:
set(CPP_FILES_REGEX "\\b(\\w|\\d)+\\b\\.(hpp|cpp|c|h)")
source_group("my_folder" FILES "${sourcers_dir}/main.cpp")
CMake's regexes are fairly basic in what they understand, see the docs. "Fancy" named classes and pseudo-classes like \b, \w or \d are not supported. You'll have to spell them out manually (i.e. use [0-9] instead of \d etc.)

Exclude folder except one subfolder via regular expression in Eclipse

I want to add a Resource Filter in Eclipse to exclude a folder named target including all it's files and subfolders except exactly one of this subfolders (target/scala-2.11/classes_managed).
Here is the regex I used for this (including examples for subdirectories):
https://regex101.com/r/aQ2qM1/1
In the referenced example it seems the regex works fine.
However when I apply this regex in Eclipse it does not work.
What's the correct way to write the regex so it works in Eclipse?
Thank you!
You don't need to get all fancy with regular expressions, you can tell eclipse to "Include only" the Folders with a Name matching:
target/scala-2.11/classes_managed
That will exclude all the files that you wish.

What is a regular expression I can use in Vim to find CVS conflicts?

What is a regular expression I can use in Vim to find conflicts in CVS and possibly other version control systems?
Here is a regular expression to find entire conflict sections:
[<]\{7}.*\_.\{-}[=]\{7}\_.\{-}[>]\{7}.*
And to search for that in vim, just press the '/' key and paste that regular-expression string, then press enter.
Usually CVS conflicts look like this:
<<<<<<< file.c
Code from file.c
=======
Code from the repository version 1.2
>>>>>>> 1.2
Vim search-and-replace command to keep local version:
:%s/[<]\{7}.*\n\(\_.\{-}\)[=]\{7}\_.\{-}[>]\{7}.*\n/\1/g
Vim search-and-replace command to keep repository version:
:%s/[<]\{7}.*\_.\{-}[=]\{7}\n\(\_.\{-}\)[>]\{7}.*\n/\1/g
I usually just do /<<< and press 'n' until I find no more matches. It is a much less sophisticated approach than Neil's, but it works for me :)

Regex pattern search in TextPad fails, works in Visual Studio

I'm trying to use TextPad to search for a regular expression in several files. I have a simple pattern but it doesn't work in TextPad. It works fine in Visual Studio.
Anyone have any ideas?
I'm searching for:
hosted.mysite.com or host.mysite.com
using the pattern:
(hosted|host)\.mysite\.com
Use something like this
\(hosted\|host\).mysite.com
try this:
host\(ed\)?\.mysite\.com
Not every text editor uses the same regex/conventions. A regex you may get to work in Visual Studio won't necessarily work in Eclipse, Netbeans, or some other IDE or text editor.
In Textpad you need to escape some characters, such as parenthesis and pipes.
In your case, what you need is this:
\(hosted\|host\)\.mysite\.com
Note: you need to escape dots as well.
Textpad's POSIX regexes are good, but even better results could be achieved by installing the Win GNU util grep and adding a cmd /c "Prompt for parameters " , "Capture output" command: thus you could have full Find in files with even Perl regexes:
grep -nhPr "CoolRegexToSearchWith" C:\MyDir\ToSearchRecursivly