Home > OS >  Consult a regular expression
Consult a regular expression

Time:09-30

Echo "ABC: cde. "123-456 | sed - r 's/(+) [^ :] (; . * :) ([^ :] + $)/\ 3/'
The output is ABC: 456

Then the echo "ABC: cde; "123-456 | sed - r 's/(+) [^ :] (; . * :) ([^ :] + $)/, 3, 3, 3 '
The output is ABC: 456456456

This is why? According to the understanding of the third group should be 456?

CodePudding user response:

The group is not right, ([^ :] +) is ABC (; . * :); 123: ([^ :] + $) is 456, that: cde

CodePudding user response:

Then you, so could not put the ABC: into account, the cde is group 1; 123: grouping is 2, 456 in group 3

CodePudding user response:

Well, the problem is a separate output a third group is ABC: 456, but a continuous output 3 phase three groups become ABC: 456456456; Here is a little hard to understand, ([^ :] + $) should match is: right, this should be a matching 456?

CodePudding user response:

reference YCM180 reply: 3/f
well, the problem is a separate output a third group is ABC: 456, but a continuous output 3 phase three groups become ABC: 456456456; Here is a little hard to understand, ([^ :] + $) should match is: right, this should be a matching 456?


You such a grouping, excluded the ABC, cde is group 1; 123: grouping is 2, 456 in group 3, you are replaced with sed, and is the cde. For group 3, 123-456, 456, the result is not ABC: 456, and then the second, the cde. 123-456 to replace three group 3, the result is ABC: 456456456

CodePudding user response:

Well, see, they understand is wrong, thank you
  • Related