开发者

Regexp to replace everything after match

开发者 https://www.devze.com 2023-04-06 02:22 出处:网络
I have the following text file content: <?php //================ Versions ================ $applicatoinversion = \'1.2.3.40\';

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

0

精彩评论

暂无评论...
验证码 换一张
取 消