[Q] how fast a Monday regular copy content

Recently the group intends to micro-channel can be out of a weekly topic, threw everyone thinking approach under question, do not necessarily have a standard answer, but there will always be more appropriate answers situation

The following questions

1  Quick Copy additional dns configuration, this is a demand encountered in dealing with domain names point to double the time to deal with hundreds of records pointing to how quickly and correctly handle the completion of
 two  of the most original profile contents
 3 address = / Jenkins .f6car.org / 10.29.128.247
 . 4 address = / kibana.f6yc.org / 10.29.128.247
 . 5 address = / auto.f6car.org / 192.168.13.103
 . 6  
. 7  needs to be changed in the following manner, i.e., each of the original records, add a org.cn suffix
 . 8 address = / jenkins.f6car.org / 10.29.128.247
 . 9 address = / jenkins.f6car.org.cn / 10.29.128.247
 10 address = / kibana.f6yc.org / 10.29.128.247
 . 11 address = / kibana .f6yc.org.cn / 10.29.128.247
 12 is address = / auto.f6car.org / 192.168.13.103
 13 is address = / auto.f6car.org.cn / 192.168.13.103

 

Topic posted only three dns records, the actual configuration of these nearly 100, if the pieces are a copy, an estimated one day without doing anything else, I have to think about how fast and province to complete this thing

Analysis of the subject, just added a new domain name at, other content is the same, but each row of data has the same law, divided into three parts, namely a fixed address first, middle name, last IP address . Newly added record and the old record only difference is that the intermediate portion increases the domain name string '.cn'

After the analysis is complete, consider how to achieve this operation, and provide two reference directions here

A reference:

The separator / the string sections of three parts, the middle part add '.cn' to a suffix, such as the use of split python, string concatenation plus interface, implementation is not lost here, you can attempt to lower their

Reference II:

Due to very regular string, consider using regular matches to complete this function, matching rules given here to a Mac Visual Studio Code

Use regular matching: (.. Address = / (+) / (+ )) \ n- 
replaced content to match: $ . 1 \ = nAddress / $ 2.cn/$3\n

Simple explain () represents a sub-mark start and end positions expression. Sub-expressions can be obtained for later use. To match these characters, use \ (and \).

Represents $ 1 back reference, for a regular expression pattern or both sides of the part of the pattern will cause the associated matched parentheses added to a temporary storage buffer, each sub-matching are captured appear from left to right in a regular expression pattern the order of storage. Buffer No. 1 from the beginning, can store up to 99 captured subexpression. In most of the other tools, the use as notepad ++ \ 1 indicates the first match back reference content.

\ N represents the newline, when the window machine to perform, depending on the compiler may have to replace \ r \ n before they can match the end of the line feed

Regular matches involving much content, but to take time to understand and grasp the exercise, once mastered can greatly improve efficiency, if not mastered, or use rusty, and then consolidated under study.

 

Guess you like

Origin www.cnblogs.com/monley/p/11223476.html