Re: More complicated search and replace situations


Gudrun Brunot
 

Excellent, Brian. I've actually read about search and replace and special characters, but I wasn't sure I understood it right. Your explanation makes it crystal clear.



Gudrun

-----Original Message-----
From: main@jfw.groups.io [mailto:main@jfw.groups.io] On Behalf Of Brian Vogel
Sent: Monday, July 11, 2016 3:16 PM
To: main@jfw.groups.io
Subject: Re: More complicated search and replace situations

On Mon, Jul 11, 2016 at 10:17 am, Gudrun Brunot wrote: "what I want to do is: search for right brace followed by any letter followed by colon followed by end quote followed by any letter followed by right brace."

Gudrun,

The search string you're looking for is: \{*:"*\}

Just to explain, since the curly brace is actually a character used as part of wildcard strings for other purposes, if you want to use one as a literal to search for you must prefix it with a backslash, which is referred to escaping the character. This is true for the other special characters, e.g., the question mark, which is normally used to denote any single character, but if you want to search for the question mark character you must escape it. If you look at the page I posted the link to previously the various special characters that are employed as part of wildcard strings, rather than being taken literally unless escaped, are shown and discussed at length.

So in the above search string, it searches for literal left curly brace followed by any number of random characters, with those random characters then followed by a colon and a double quotation mark, then followed by any number of characters terminated by a literal right curly brace.

You can use whatever you'd like as your replace string. I often use some really odd character, like the tilde, just because those are much easier to find afterward than, say space, and easier to replace with whatever you'd like. Of course, I only do this if there is some question as to what might get replaced. If you're positive that the format you specified is only going to match what you think it should then replace it with whatever makes sense to you.

--

Brian



A great many people think they are thinking when they are merely rearranging their prejudices.

~ William James

Join main@jfw.groups.io to automatically receive all group messages.