Hello,
I want to duplicate a line and modify only a part of it. I used the following regular expressions in POSIX to replace my line but it didn't work:
replace: command ([.]*)
by: command \1\nnewcommand \1
---
Example:
text to replace:
command attributes
command other attributes
expected result:
command attributes
newcommand attributes
command other attributes
newcommand other attributes
result with my regexp:
command
newcommand attributes
command
newcommand other attributes
---
How come that \1 is only applied at the last occurence?
Regards,
Luoji.
Regular Expression: using \1 twice
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Re: Regular Expression: using \1 twice
Very interesting! Don't put "[]" around the "." and it works! I don't know exactly why but the "[]" are at least not necessary because "." already matches any character.
Re: Regular Expression: using \1 twice
[.] matches a . and nothing else
while . matches any character
Within [], most special characters are not special any longer!
See Help/Help Topics/Contents/Reference Information/Regular Expressions/Special Characters
while . matches any character
Within [], most special characters are not special any longer!
See Help/Help Topics/Contents/Reference Information/Regular Expressions/Special Characters