Search tool that uses a grammar rather than regular expression? - search

Are there any search tools that allow you to set up a simple token/grammar parsing system that work similar to regular expressions?
What we want to do is search our ColdFusion code for queries that do not have cfqueryparams in them.
A regular expression gets a bit tough in this situation because I can't keep track of the start tags while looking for something else before getting an end tag.
It seems like a parsing system would work more accurately.

Seeing it is XML, I would just use XSLT.

Related

How to disable query of a keyword in Google?

Let's say that I have a set of keywords that I don't want to see in my future Google search results page: {"Naruto","Toriko","One Piece","Conan"} (these are names of anime that I want to quit). Is there a way I can write a lightweight script or something so that whenever I use Google, it filters out pages containing those words? Even if I explicitly search for "Naruto", to Google the query is actually "Naruto -Naruto" so Google won't return anything. It's easy to ignore certain keywords for a single query using advanced search, but how do I ignore a set of keywords for all my queries in the future?
What is the best way to do this? A Chrome extension? A perl script? A javascript? How can I implement this feature for myself? What tools/languages should I use?
This is probably done best in your browser. For example, you could write a Firefox extension to do this. (It would probably even be worth publishing -- others may want this functionality (like parents).)

creating tags for a script language for easy browsing in vim

I use ctags+Vim for a lot of my projects and I really like the ability to easily browse through large chunks of code quickly.
I am also using Stata, a statistical package, which has a script language. Even though you can have routines in the code, its code tends to be series of commands that perform data and statistics operations. And the code files can be very long. So I always find myself in need of a way to browse it efficiently.
Since I use Vim, I can use marks. But I was wondering if I could use ctags to do this. That is, I want to create a tag marker which (1) won't cause a problem when I run the script (2) easy to introduce to ctags.
Because it is supposed to not break the script, it needs to be a comment. In Stata, comment lines start with * and flow comments can be made by /* ..... */.
It would be great, for example, have sections in the code, marked by comments:
* Section: Data
And ctags picks up "Data Manipulation" as the tag. So I can see a list of sections and jump to them easily without the needs for creating marks.
Is there anyway to do this? I'd appreciate any comments.
You need a way to generate a tags database for your Stata files. The format is simple, see :help tags-file-format. The default tags program, Exuberant Ctags can be extended with regular expressions (--langmap, --regex); that probably only yields an approximate parsing for complex languages, but it should suffice for custom section marks; maybe you could even directly extract interesting language keywords.

Search and replace strings in PDF with Perl, Ruby, or PHP

Is there a way to script replacing strings in PDF documents? I can use either Perl, Ruby or PHP. If possible, a regular expression would be a great.
As part of my open-source CAM::PDF Perl library, I include a tiny front-end program called changepagestring.pl which does what you ask.
However, it only replaces text that's contiguous in the PDF syntax. If you switch fonts, size, style, etc. mid-phrase then it won't match. If you do any advanced kerning then it won't match.
Those limitations aside, it's really easy to use and it's simple enough that you can easily fork it and hack it to your needs.
In Perl, you can parse the contents of your PDF using the PDF::API2 module. You should then be able to search and replace your target strings in the usual way (s///), and write the new document back to disk.

Text indexer search tool which can filter by punctuation?

This is not a programming question per se but a question about searching source code files, which help me in programming.
I use a search tool, X1, which quickly tells me which source code files contain some keywords I am looking for. However it doesn't work well for keywords which have punctuation attached to them. For example, if I search for "show()", X1 shows everything that has "show" in it including the too many results from "MessageBox.Show(.....)" which I don't want to see.
Another example: I need to filter to show ".parent" (notice the dot) and not show everything that has "parent" (no dot) in it.
Anyone knows a text search tool which can filter by keywords that have punctuation? I really prefer a desktop app instead of web based tool like Google (I find it clunky).
I am looking for a tool which indexes words and not a general file searcher like Windows File Explorer.
If you want to search code files efficiently for keywords and punctuation,
consider the SD Source Code Search Engine. It indexes each source langauge according
to langage-specific rules, so it knows exactly the identifiers, keywords,
strings, comments, operators in that langauge and indexes it according to
those elements. It will handle a wide variety of languages: C, C++, Java, VB6, C#, COBOL,
all at once.
Your first query would be posed as:
I=show - I=MessageBox ... '('
(locate identifiers named "show" but eliminate those that are overlapped by
MessageBox leftparen).
You second query would be posed as simply
'.' I=parent
See http://www.semanticdesigns.com/Products/SearchEngine/index.html
It seem to be the job of tools like ctags and cscope.
Ctags is used to index declarations of source files (many languages supported) and Cscope for in-depth c file analysis.
These tools are more suited for a per project use in my opinion. Moreover, you may need to use another tool to use these index, I use vim myself for this purpose, but many text editors use ctags.
The tool from DTSearch.com.

What non-web-based tools exist to view IIS logs?

I'm looking for non-web-based tools to view IIS logs. I've been using LogParser but I was hoping for something with an interface. It doesn't need to do any fancy reports or charts -- just a list with some search filters is plenty. I need something lightweight that I can run directly on the web server, preferably without a complex install process.
VisualLogParser wraps Log Parser in a GUI. I'm sure there are others as well, but it's fit the bill for me. All the yumminess of Log Parser, with a half-decent interface.
I find that command-line tools are often enough. For example, to list all log entries with a 404 response:
findstr "404" logfilename > out.txt
Findstr supports regular expressions in the search term and wildcards in the filename, so it is quite flexible for dealing with logfiles.
I'm intrigued why you need more of an "interface" than the command line interface already provided by LogParser? Are you struggling with the SQL-like syntax maybe or is there something else?
LogParser ticks ALL your other requirements. It totally rocks my socks.
Nothing beats log parser. However, you may want to check out Sawmill & splunk.

Resources