开发者

Translation rule

开发者 https://www.devze.com 2023-04-07 03:00 出处:网络
I like to create a translation rule to a VoIP system to o开发者_JS百科btain the following result:

I like to create a translation rule to a VoIP system to o开发者_JS百科btain the following result: If someone dials the 4545 the system must convert this to 1234545, I managed to do this with the following rule: s/^4545/1234545/

My problem now is if someone dials 454567 my rule will convert this to 123454567 and I want to get 1234545 thx


Not clear on why should 454567 become 1234545? Should a string with a run of 4545 anywhere in it be come 1234545?

If you just want to change the exact string 4545 to 1234545 then you can use s/^4545$/1234545/.

If you want a string with a run of 4545 anywhere in it to become 1234545 then you can use s/.*4545.*/1234545.


$number='1234545' if ($number eq '4545'); #eq because phone number can contain non-digits.

If you want to convert any number that starts with '4545', use this code:

s/^4545.*/1234545/
0

精彩评论

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