Hi,
I have a large file that has imbedded control codes in it that I need to change to HTML tags. The code I am interested in changing is for italics. The file uses a \i to begin italics and another \i to end them.
Any help on how I can change these to HTML tags would be much appreciated!
Karen
Help with Search/Replace
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- webber123456
- Posts: 50
- Joined: Wed Jul 30, 2003 2:55 am
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Because the same symbol is used to start and end the italicised text, this is quite hard.
If each section of italicised text begins and ends on the same line, and if there is at most one such section on any one line, then you can use the following:
It also doesn't work in TextPad if there is more than one italicised section on one line, as the above regular expression will match everything from the first \i on the line to the last \i on the line. If there are no backslahes (\) within the italicised sections, you can avoid this problem with
If each section of italicised text begins and ends on the same line, and if there is at most one such section on any one line, then you can use the following:
This assumes you are using POSIX regular expression syntax:Find what: \\i(.*)\\i
Replace with: <i>\1</i>
[X] Regular expression
This doesn't work in TextPad if the italicised sections span newlines, as TextPad's regular expression recogniser doesn't support regular expressions containing variable numbers of newlines.Configuration | Preferences | Editor
[X] Use POSIX regular expression syntax
It also doesn't work in TextPad if there is more than one italicised section on one line, as the above regular expression will match everything from the first \i on the line to the last \i on the line. If there are no backslahes (\) within the italicised sections, you can avoid this problem with
Better solutions are available with WildEdit (http://www.textpad.com/products/wildedit/), which uses the far more powerful Boost regular expression recogniser. In WildEditFind what: \\i([^\]*)\\i
Replace with: <i>\1</i>
[X] Regular expression
matches lazily (matching the shortest subexpression instead of the longest), solving the second problem above. And you can choose to have a dot (.) match newlines, solving the first problem.Find what: \\i(.*?)\\i