Batch add characters and other common regular expressions at the beginning and end of the EditPlus line.

Source: Internet
Author: User

Batch add characters and other common regular expressions at the beginning and end of the EditPlus line.

Open EditPlus and enter multiple lines of data. Press ctrl + h to open the Replace window and select "Regular Expression" to replace


Batch Add at the beginning of a rowReplace "^" with "I am the first aaa"

Batch Add at the end of a rowReplace "\ n" with "'bbb I am the end of the line \ n"

Delete blank rows^ [\ T] * \ n


Editplus searches for the replaced regular expression. The application expression description \ t tab. \ n new line .. match any character. | match the characters on the left and right of the expression. for example, "AB | bc" matches "AB" or "bc ". [] match any single character in the list. for example, "[AB]" matches "a" or "B ". "[0-9]" matches any number. [^] matches any single character out of the list. for example, "[^ AB]" matches characters other than "a" and "B. "[^ 0-9]" matches any non-numeric characters. * The character on the left is matched any time (0 or multiple times ). for example, "be *" matches "B", "be", or "bee ". + The character on the left is matched at least once (once or multiple times ). for example, "be +" matches "be" or "bee" but does not match "B ".? The character on the left is matched 0 times or 1 time. For example, "be? "Match" B "or" be "but not" bee ". ^ The expression on the right is matched at the beginning of a row. for example, "^ A" only matches rows starting with ". contentnbsp; the expression on the left is matched at the end of a row. for example, "econtentquot; only matches the rows ending with" e. () affects the order of expression matching and is used as the grouping tag of the expression. \ escape character. if you want to use "\", you should use "\\". apply a regular expression -- delete the null row ^ [\ t] * \ n expression group and use () to mark it. the expression group can be referenced as \ 0, \ 1, \ 2, \ 3, and so on. \ 0 indicates all matched strings. \ 1 indicates the first group to be matched, \ 2 indicates the second group, and so on. for example. original search replacement result abc (AB) (c) \ 0-\ 1-\ 2 abc-AB-cabc a (B) (c) \ 0-\ 1-\ 2 abc-B-cabc (a) B (c) \ 0-\ 1-\ 2 abc-a-c [1] Regular Expression Application -- replace the specified content with the original text at the end of the line, as shown in the following two lines of abc aaaaa123 abc 444 each time abc ", then, replace "abc" and the content from the end to the end of the line with "abc efg". That is, the text above is replaced with abc efg123 abc efg. Solution: ① In the replace dialog box, enter "abc. * "② select the" Regular Expression "check box and click" replace all ". The meaning of the symbol is as follows:". "= match any character" * "= match 0 times or more note: in fact, it is a regular expression replacement. Here we just sort out some questions that have been raised, from the regular expression itself, thousands of special cases can be extended. [2] apply a regular expression -- replace a number to replace asdadas123asdas456asdasd789asdasd with asdadas [123] asdasdas [456] asdasdasd [789] asdasd in the replace dialog box. Select the regular expression check box; enter "[0-9] [0-9] [0-9] [0-9]" in the search content, without quotation marks. "replace: enter "[\ 0 \ 1 \ 2]", excluding the quotation mark range for the operation range, and then select replace. In fact, this is a special case for regular expressions. "[0-9]" indicates matching 0 ~ For any special case between 9, "[a-z]" indicates matching ~ In any special case between z, "[0-9]" is repeatedly used. the three consecutive numbers \ 0 represent the prototype corresponding to the first [0-9, "\ 1" indicates the prototype corresponding to the second "[0-9]". Therefore, the "[" and "]" are pure characters, "[" or "]" is added. If "Other \ 0 \ 1 \ 2" is input, the result is replaced: asdadas other 123 other asdasdas other 456 other asdasdasd other 789 other asdasd function enhancements (by jiuk2k ): if you change "[0-9] [0-9] [0-9]" to "[0-9] * [0-9]", corresponding to 1, 123, 12345, or... There are many other customized content as needed, you can refer to the regular expression syntax for a closer look [3] Regular Expression Application -- delete the specified characters at the end of each row because these characters also appear in the row, therefore, it is certainly not possible to simply replace the regular expression. For example, if 12345 12653452345 needs to delete the "345" at the end of each line, it is also considered a regular expression usage. In fact, it is easier to look at the regular expression carefully, however, since this problem is raised, it means that you have to understand the regular expression. The solution is as follows: In the replace dialog box, enable the "Regular Expression" check box and enter "345 contentrdquo;" indicates matching from the end of the line. If matching from the beginning of the line, you can use "^, however, EditPlus has another function to easily Delete the string a at the beginning of a row. select Row B. edit-format-Delete row comment c. in the pop-up dialog box, enter the first character of the line to be cleared, and then click [4] Regular Expression Application -- replace the following code in several hundred web pages of multiple lines with half angle brackets: \ n is being replaced Enable the "Regular Expression" option in the dialog box, and then replace [5] Regular Expression application-delete blank lines to start EditPlus and open the text files to be processed. ① Select the "replace" command in the "Search" menu to bring up the text replacement dialog box. Select the "Regular Expression" check box, indicating that we want to use a regular expression in search and replacement. Then, select "current file" in "replacement range" to operate the current file. 2. click the button on the right of the "search content" combo box. A drop-down menu is displayed. ③ The following Operation adds a regular expression, which represents the blank row to be searched. (Tip: A blank line only contains space characters, tabs, and carriage returns. It must start with one of the three symbols and end with a carriage return, the key to searching for empty rows is to construct a regular expression that represents empty rows ). Enter the regular expression "^ [\ t] * \ n" in "Search". Note that there is a space character before \ t. (1) Select "match from the beginning of the line", and the character "^" appears in the "search content" combo box, indicating that the string to be searched must appear at the beginning of the line in the text. (2) If you select "character in the range", a pair of brackets "[]" will be added after "^". The current insertion point is in the brackets. In regular expressions, brackets indicate that any character in the text matches the matching conditions. (3) press the Space key to add a space character. A space character is a component of a blank line. (4) Select "tab" and add "\ t" representing the tab ". (5) move the cursor, move the current insertion point to "]", and select "Match 0 times or more". This operation adds the asterisk (*). Asterisk indicates the space character or Tab character in the brackets "[]" in front of it. There are 0 or more characters in a row. (6) Select "linefeed" and insert "\ n" to indicate a carriage return. ④ The "Replace with" combo box is left empty, indicating that the searched content is deleted. Click "replace" to delete empty rows one by one, or click "replace all" to delete all empty rows (Note: EditPlus sometimes has the problem that "replace all" cannot completely delete empty rows at a time, it may be a program BUG. You need to press the button several more times ).


Door: requires batch processing to insert different specified characters at the beginning and end of the first line of the batch text file

Modify the txt file in the current folder
@ Echo offset "Beginning of a line = $" set "end of a line ####" for % a in (*. txt) do (set ". = "(for/f" tokens = 1 * delims =: "% a in ('findstr/n. * "% a" ') do (if defined. (echo, % B) else (if not "% B" = "" (set. =. echo % beginning of line % B % end of line %)> $ move $ "% ")

How to add text at the beginning and end of the line in txt

You can simply Replace the software Replace Pioneer to add content at the beginning and end of the line. Detailed steps:
Ctrl-o open a text file
Ctrl-h Open the replace window
* Replace unit select Line
* Replace with pattern input:
<RefuseItemModel> <ItemNumIid> $ match </ItemNumIid> <MinPrice>-0.20 </MinPrice> <MaxPrice>-0.10 </MaxPrice> </RefuseItemModel> \ n
Click replace.
Ctrl-s.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.