首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于regex的msisdn元素删除

基于regex的msisdn元素删除
EN

Stack Overflow用户
提问于 2019-05-15 11:34:28
回答 1查看 116关注 0票数 1

我试图从to 3.11上的MO调用中删除msisdn字段,但它不处理所需的内容。

我想设置一个条件,如果Msisdn没有从962开始,那么删除元素。

我的背景仅限于python,这是第一次使用perl。我使用它是因为在搜索之后,我相信只有perl才能处理TAP文件。

代码语言:javascript
复制
# Will scan all the calls for MTC's.
foreach $key ( @{$struct->{'transferBatch'}->{'callEventDetails'} } ) {

    foreach ( keys %{$key} ) {

        if ( $_ eq "mobileOriginatedCall" )
        {
            if ( defined $key->{$_}->{'basicCallInformation'} )
            {
                if ( defined $key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'} )
                {
                    if ( defined $key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'})
                    {
                        if ( defined $key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'})
                        {
                            if ($key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'} =~ /^[962]/)
                            {
                                $key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'}=();
                            }
                        }
                    }
                }
            }
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-15 12:06:42

试着:

代码语言:javascript
复制
...
if ($key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'} =~ /^(?!962)/)
{
    delete $key->{$_}->{'basicCallInformation'}->{'chargeableSubscriber'}->{'simChargeableSubscriber'}->{'msisdn'};
}

更改:

要删除密钥,请使用删除

对于"not starting with“regex,请使用:^(?!WHATEVER),例如^(?!962)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56148404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档