In the sublime text editor, how do you search recursively in a directory for only certain file types? E.g. in a directory for all *.cc and *.h files?
Specify the path in the Find 'Where' field and wildcards after the path seperated by commas.
e.g. /path/to/search,*.cc,*.h
You can also exclude file-types with the minus '-' character: /path/,-*.xml
Related
I have this path in my react gulpfile:
var path = {
HTML: 'src/index.html',
ALL: ['src/js/*.js', 'src/js/**/*.js', 'src/index.html'],
JS: ['src/js/*.js', 'src/js/**/*.js'],
MINIFIED_OUT: 'build.min.js',
DEST_SRC: 'dist/src',
DEST_BUILD: 'dist/build',
DEST: 'dist'
};
What is the double glob character?
I know what the single glob is... but what is the double?
single glob
It's almost the same as the single asterisk but may consist of multiple directory levels.
In other words, while /x/*/y will match entries like:
/x/a/y
/x/b/y
and so on (with only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like:
/x/any/number/of/levels/y
with the concept of "any number of levels" also including zero (in other words, /x/**/y will match /x/y as one of its choices).
As an aside, as much as I hate to credit the mainframe with anything, I believe this has been used since the earlist days of MVS to allow selection of datasets at multiple levels :-)
** matches any character including a forward-slash /
* matches any character except a forward-slash (to match just the file or directory name)
It's usually used to indicate any number of subdirectories. So
src/js/**/*.js
Would match
src/js/files/*.js
src/js/more-files/*.js
etc
etc
Like Grunt, the double ** is saying, "Look in all the subfolders
within js and for all of the .js files."
You can actually refer here for the same:
https://www.codefellows.org/blog/quick-intro-to-gulp-js
When I simply use
FileHelper::findFiles(realpath($config['sourcePath']));
It works.But when I try to pass some options to it,it does not work.Unfortunately,It does not give any error.
FileHelper::findFiles(realpath($config['sourcePath']),['only'=>['*.php']]);
Any idea why is it so?
The syntax should be .php and not *.php. It isn't very clear in the docs though. Here is the explanation for the trailing /:
For example, '/a/b' matches all file paths ending with '/a/b'; and '.svn/' matches directory paths ending with '.svn'
We can therefore deduce that .svn will match all files ending in .svn.
I am trying to find and replace all for loops in my (js) code with slightly different syntax. I want to find every for loop that used the syntax "for ( any code here ){". Is there a way to find all such instances?
That's a regular expression question I think. In SublimeText2 start the search functionality. Make sure regular expressions are on (first button, labeled .*) and the search for for\s*\(.*?\)\s*\{.
Enable the regex option and type for \(.+\)\{
Explanation:
the backslashes "escape" the parentheses and brace. In other words, they tell the regex that those are the characters within the search and not part of a regex command. The . searches for any character and the + modifies that to include one or more instances of any character.
Here's a screen shot of sublime text
You want to search by regular expression. Notepad++ supports this, not sure about Sublime Text but I would image it does also. With regular expression enabled, search for
xx.+xx
This will search for the characters xx, followed by any character (.) as many times as it can find it (+), followed by the characters xx. This should give you the result you are looking for.
Here is a article with some information about using regular expressions in Notepad++
I have a very basic understanding of regexp. I have searched and searched the internet for this.....
I have a linux server which only likes lowercase file names and I stupidly have image filenames in title case!
I want to batch find all jpg pathnames in my HTML files and convert them into all lowercase with Regex.
My-File-Name1.jpg needs to be my-file-name1.jpg
I think I need a regex expression to find them all, and another that replaces them converted into lowercase.
Any help?
EDIT
#Sniffer gave me the regex that gets the filename path.
In notepad ++ find and replace using regex. You can use
([\w/-]+)\.jpe?g to find image pathnames and
: \L\1 to change to lowercase and using replace
\U\2 to change to higher case using replace
I found the lower/uppercase regex here http://sourceforge.net/p/notepad-plus/discussion/331754/thread/ecb11904/
Usually I would say use an HTML parser which is the best tool for the job here but since you only want jpg files then you might be able to find them all by using the following:
([\w/-]+)\.jpe?g
^
|
|
As you can see I have added the forward slash / and the dash - to the
character class, WARNING: the dash - should always be the last character in the
class, keep that in mind if you have more special characters.
You will have to match this globally in your file.
As for the conversion, it can't be done using a regex. You will have to call an API that converts a string to lower case, and use it on the captured groub $1.
I wonder if there is any way to generate culture neutral CSV file or at least specify data format of certian columns present in file.
For example I generated CSV file that contains numbers with decimal separator (.), and after
pass it to the client which is in the country where decimal separator is (,), client opens it with Excel and sees all values changed.
Is there any way to resolve this isure, or just in this case do not use CSV file ?
Thank you in advance.
What you want is a "quoted CSV file".
That is as well as separating your values with commas you also enclose them in (usually) double quotes.
Like so:-
"first","second","3,00","Some other text, etc."
This format is quite common and supported by EXCEL.
Two ways I came up with to avoid the decimal separator altogether:
1) Use scientific notation, so 1.25 would be: 123E-2
2) Make it a formula, so 1.25 would be: =125/100
Both pretty crappy, depending on your target audience, but at least Excel sees them as numbers and can calculate with them.
A CSV file will be separated by commas (the 'C' in CSV) but you can output a text with any delimiter and qualifier and you'll be able to open it in Excel - you specify them in the step 2 of the import text wizard.
A common choice for situations like this is to use tabs (TSV).
You can use Tab Separated Values, which does not vary between cultures and are supported by Microsoft Excel. Common file extensions are .tsv and .tab.
http://en.wikipedia.org/wiki/Tab-separated_values