RoboHelp 10 - Find and Replace
The Find and Replace in Files function has been completely changed and now appears in a pod. You can globally find and replace text, HTML tags, and attributes in the current project or across files and folders. RoboHelp displays the results in the Find Results pod and also lets you open each modified file in the Find Results Editor pod (HTML view).
As with any multi file find and replace tool, create a backup of your project before you start. These tools can wreck a project quicker than they can repair it!
Basic Mode
Basic mode has two sets of filters. At its simplest, you have just the basic filters as below.
The chevrons are pointing to the right to indicate you are in Basic Mode.
Then you can toggle the Show Options / Hide Options button for additional filters that are self explanatory. If you are not familiar with Regular Expressions, they are arguably the most advanced way of searching so to my mind the option should be in the Advanced Mode. Better still, just show all the options. However, this does not affect the functionality of regular expressions, more on that below.
Advanced Mode
In Advanced mode the chevrons are now left facing and the highlighted area is revealed.
Do not use the Does Not Contain field. It contains a bug that will Find the wrong string.
A word of warning here. Underpinning these advanced filters are regular expressions and there is a bug in the Does Not Contain filter. See Regular Expressions below to learn more about that.
Screenshot
Note that Find and Replace in Files works at HTML code level. That means it can find tags and change them as well, so be careful.
Regular Expresssions - Regex
What are regular expressions?
The easiest way to think of them is as a formula to find a string of text. If you only want to find every instance of "red" and change it to "blue" then you search for the string "red". Sometimes though you want to search for a string that starts with a particular word and ends with a particular word but may contain very different words in between and those word must or must not contain another word. A formula is required for that and it is beyond the scope of this page to provide a tutorial on that.
See Wikepedia or Regular-Expressions.info or Links on my site to learn more.
For those of you who are familiar with regex, there is a gotcha in the implementation. Typically where you use regex to find a string, you also use regex in the replace string. Unfortunately the replace only works with literal text!
The Bug
A little understanding of regular expressions is required to explain this. Regex can be lazy or greedy.
-
A lazy expression will find the next instance of the string and stop searching so Begins With = Red, Ends With = Green and Contains = Blue will find the next string that starts with Red and select all text until it reaches the next instance of Green, provided that string contains Blue somewhere in it. If the string does not contain Blue, the next instance of Red will be found and the same logic will be applied.
-
Where the expression is greedy, it will find the next instance of Red and then seek the last instance of Green in the file.
Example - Lazy Expression.
A lazy expression will find the first string shown in blue and you can then choose to Replace or Find Next. Find Next will move to the second string shown in blue
The red house has a blue door and a green roof. It has a garage with brown doors. The garden has red apples, blue flowers and green grass.
Example - Greedy Expression
A greedy expression will find the next instance of red and then look for the last instance of green, thus it will find what is shown in blue here.
The red house has a blue door and a green roof. It has a garage with brown doors. The garden has red apples, blue flowers and green grass.
Summary
Generally a very welcome upgrade of this feature but unfortunately marred by a dangerous bug and the inability to use regex in the replace string. Provided you are conscious of those shortcomings, it otherwise works nicely.