I have the following text file content:
<?php
//================ Versions ================
$applicatoinversion = '1.2.3.40';
$someothervariable = 'td11';
$dbversion = '2.3.1.4';
Other开发者_运维百科 code here
?>
I need to replace everything EXCEPT the (application) version number with an empty string. So I can save the following file:
1.2.3.40
I'm not using a programmig language so I need to do it only with regular expression replace.
So far can match the version number:
(?<=\$applicatoinversion = \')(([0-9]\.){1,3}([0-9])+)(?=\';)
And managed to match everything before:
(.|\n)*(?=
(?<=\$applicatoinversion = \')(([0-9]\.){1,3}([0-9])+)(?=\';)
)
But I'm stuck. I cant match everything BEFORE and AFTER version number. Any gurus here?
Thanks in advance
(?s).*applicatoinversion = '(([0-9]\.){1,3}([0-9])+)'.*
just replace all with the match from group 1
精彩评论