Quantcast
Channel: Domino Designer – Xcellerant
Viewing all articles
Browse latest Browse all 4

Domino Designer Tip – RegEx Searching for a String with Single or Double Quotes

$
0
0

If you’re looking for a string value in code throughout your application, it can sometimes be frustrating to weed through extraneous results. If you know the exact string, you can make the search more efficient by including the quotes in the search. However, if you’re working on someone else’s (because you would never do that) application where there’s inconsistent usage of single and double quotes throughout the code, you either have to search twice or you may miss some results. In this post, I’ll show how to do a single search to find all instances in single or double quotes.

Example

Here’s a bad example that I can easily use as a straw man to illustrate the point.

I created an empty NSF and added two script libraries.

One has this line:
var x = 'doc';

The other has this line:
var x = "doc";

A search for doc (without quotes) brings back 13 results because it’s part of a bunch of words. And this is in an otherwise empty NSF.

RegexSearch_A

In order to narrow the results, I can limit the search by wrapping the search term in quotes to find only instances of the full string. In this example, I searched for "doc"

RegexSearch_B_DocDblQuotes

This search only found the instance that used double quotes, but it misses the other instance in single quotes.

RegEx to the Rescue

Fortunately, Eclipse search can handle regular expressions. (H/T to Jessie Gallagher for that tip awhile back.)

Just check the ‘Regular expression’ box and use regex syntax for finding one of multiple characters (square brackets) to build a search string that will find the value with either single or double quotes.

["']doc["']

RegEx_SearchBox

And now I get the results I was looking for, including the term in both single and double quotes.

RegexSearch_C_BothQuotes

Note: If you only know part of the term, you can use wildcards or just include the quote search on one end of the term.



Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images