Easy Replace support batch replacement via replace script file(.rep) composed of sets of replacing commands(as RepCmd below).
Ultra Replace uses a special designed regulation to write replacing commands. Here's a list of the reserved key words:
Key Word | Explanation | |
---|---|---|
rep | beginning a replacing command, followed with what you want to replace, or replace from | |
regrep | replace in Regular Expression mode | |
cs | case sensitive (default is insensitive) | optional |
to | followed with the end of the part you want to replace | optional |
with | followed with substitute | optional |
--- | expression delimiter(you can define yours) | |
; | terminator of a replacing command | |
/// | comment introducer (one more slash than C++ comment) | |
===XXXX=== | comment block | |
!delimiter="x" | user defined delimiter declaration | optional |
$$begin | expression of the start of file | |
$$end | expression of the end of file |
Here's a simple standard replacing command:
rep|regrep [cs] ---a---[ to ---b---][ with ---c---];
(Inside [ and ] is optional, on both sidesof | are selectable.)
Here's the simple standard replacing command,
rep ---a--- to ---b--- with ---c---;
This command means we want the part from a to b to be replaced with expression c, and all expressions are normal expression and this replacement should be in case insensitive mode.
Another simple command
regrep ---a--- with ---c---;
means we want all part in source text that matched expression a to be replaced with expression c, expression a and c is consider as Regular Expression (even if they are normal expression). You should not write "to" expression in a regrep command, the "to" expression will no effective in Regular Expression mode.
When you want to delete something, that means replace it with nothing, the last with expression can be omitted. such as
rep ---a---;
This style of repcmd is very common in our examples, it equals to
rep ---a--- with ------;
You may also want to insert something at some position, that's very easy, you should replace the position identifier with what you want to insert and the identifier, such as
rep ---(id)--- with ---inserted-words(id)---;
Here we use (id) as the identifier.
Sometimes you just know the splitter, one boundary of the part you want to replace, for example, you want to delete all information before body tag of a HTML file, but the beginning of the file may not always be <html>, so how to write the expression? Now, we need the keyword "$$begin", you can write like this,
rep ---$$begin--- to ---<body--- with ---<html><body---;
You can add your head information into with expression, be careful, there's no > after <body , because there may be attributes inside the tag.
Line breaks inside expression is acceptable, so you can copy the source code directly, for example
rep ---line1
line2
line3---
with ---new line1
new line2---;
This command means - replace the paragraph composed of three lines with another paragrpah of two lines. it equals to
regrep ---line1\r\nline2\r\nline3\r\rn---
with ---new line1\r\nnew line2\r\n---;
As you can see, rep commands can be writen in mutli-lines, you can start a new line with "to" or "with" expression, such as,
rep ---a---
to ---b---
with ---c---;
it would be more easy to read, but be casreful, newline inside expression would be considered as the part of the expression, so you can't break a very long expression into lines, for example,
rep ---abcdabcd---;
can't be written as
rep ---abcd
abcd---;
Maybe only the body of the existing files are useful to you, and you want to delete all original head info, replace them with your info, such as title, meta info or CSS. The easiest way is to replace codes between head tags.
rep ---<head>--- to ---</head>--- with ---new head info---;
A standard structure of html head is often between <head> and </head>, but for some html file, there could be doctype before <html> tag or or javascript between </head> and <body>, so if you want all information before body tag to be replaced by your information, you can use the command with keyword $$begin as we have mentioned above.
Javascript comment lines always begin with '//', so we can delete words from '//' to the end of the line.
You can write:
rep ---//--- to ---
---;
Yes, you can type a enter directly as the newline character, without writing a escaped line break "\r\n" in Regular Expression mode. This command equals to,
regrep ---//.+?\r\n---;
rep ---abc --- abcd---;
rep ---abc ------;abcd---;
rep ---abc;--- with ---d.---;
rep ---;--- with ---.---;
rep ---a---;rep ---b---;
'1. rep ---a---;'
'1.rep ---a---;'
I think you should already know why I use '---' to enclose expressions, if we use some simple symbols, such as single quotes or double quotes, the string delimiters of most computer languages, the replace command would be very easily to be broken or wrong, because there would be likely single quotes or double quotes or parentheses in your expression. So '---' is a proper choice, and it's much more simple and easy to read than others like '$$$' or '###'.
But if you define yourself delimiter, be aware of your source file, there should be no our key words with your delimiter together. For example, if you define "#" as your delimiter, you should avoid "#;" , "# to #" and "# with #" in your expressions.
If your define "-" as delimiter, and you write "rep -<!--- to --->-;" to remove HTML comments, the inner "-" inside two "-" will not break the whole command, but it will be confusing to read.
At last, we provide a delimiter declaration method for user to define other delimiters. Whether the delimiter can work properly depends on expression content and complicacy. If you are sure of your delimiter, you can write as simple as you like.
For example, in my testing, a "%" can work in most occasion, but it seems toghter with expression, not clear to read. So I would rather use a long delimiter "---" for its safety and clarification.