C
cibalo
Hello,
I have updated/modified my mysql database in my free website recently.
I have to re-code all my php files such that an extra statement has to
be inserted before the last mysql_query call. It may have more than
one mysql_query call in some of my php files.
I try to use a negative look-ahead assertion to make such a change as
follows.
I would like to insert just one "new_insert" line before the "coding
line 4". And my php file looks like this.
$ echo -e "coding line 1 test 1\ncoding line 2 mysql_query 2\ncoding
line 3 test 3\ncoding line 4 mysql_query 4\ncoding line 5 test 5"
coding line 1 test 1
coding line 2 mysql_query 2
coding line 3 test 3
coding line 4 mysql_query 4
coding line 5 test 5
Then I perl-regex with negative look-ahead assertion in multi-line
mode (/smg or /sg or /mg) like this:
$ echo -e "coding line 1 test 1\ncoding line 2 mysql_query 2\ncoding
line 3 test 3\ncoding line 4 mysql_query 4\ncoding line 5 test 5" |
perl -pe '/mysql_query(?!.*mysql_query)/smg && print "new_insert\n"'
coding line 1 test 1
new_insert
coding line 2 mysql_query 2
coding line 3 test 3
new_insert
coding line 4 mysql_query 4
coding line 5 test 5
However, my "coding line 2" gets changed too. And that is not what I'm
looking for.
Or, perl negative look-ahead assertion doesn't like me! Can you please
let me know what I'm missing?
Thank you very much in advance!!!
Best Regards,
cibalo
I have updated/modified my mysql database in my free website recently.
I have to re-code all my php files such that an extra statement has to
be inserted before the last mysql_query call. It may have more than
one mysql_query call in some of my php files.
I try to use a negative look-ahead assertion to make such a change as
follows.
I would like to insert just one "new_insert" line before the "coding
line 4". And my php file looks like this.
$ echo -e "coding line 1 test 1\ncoding line 2 mysql_query 2\ncoding
line 3 test 3\ncoding line 4 mysql_query 4\ncoding line 5 test 5"
coding line 1 test 1
coding line 2 mysql_query 2
coding line 3 test 3
coding line 4 mysql_query 4
coding line 5 test 5
Then I perl-regex with negative look-ahead assertion in multi-line
mode (/smg or /sg or /mg) like this:
$ echo -e "coding line 1 test 1\ncoding line 2 mysql_query 2\ncoding
line 3 test 3\ncoding line 4 mysql_query 4\ncoding line 5 test 5" |
perl -pe '/mysql_query(?!.*mysql_query)/smg && print "new_insert\n"'
coding line 1 test 1
new_insert
coding line 2 mysql_query 2
coding line 3 test 3
new_insert
coding line 4 mysql_query 4
coding line 5 test 5
However, my "coding line 2" gets changed too. And that is not what I'm
looking for.
Or, perl negative look-ahead assertion doesn't like me! Can you please
let me know what I'm missing?
Thank you very much in advance!!!
Best Regards,
cibalo