Name Vornamesip:0813893511@b2b.domain
0813893511sip:0813893511@b2b.domain
Name Vorname 0813893511
0813893511
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#! /usr/bin/perl use strict; use warnings; use 5.010; my $known = "Name Vornamesip:0813893511\@b2b.domain"; my $unknown = "0813893511sip:0813893511\@b2b.domain"; # reformat one caller string sub reformat_caller { my $caller = shift; my ( $name, $number ) = split m{sip:|@}, $caller; # use $name as long as it does not contain only digits my $result = $name . " " if $name !~ m/^\d+$/; # alternative, $name should not be the same as $number #my $result = $name . " " if $name ne $number; # always use $number $result .= $number; return $result; } for my $caller ( $known, $unknown ) { # pretty print caller string say reformat_caller($caller); }
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl use strict; use warnings; use 5.010; for (q(Name Vornamesip:0813893511@b2b.domain), q(0813893511sip:0813893511@b2b.domain)) { /(\w+ \w+)?sip:(\d+)\@.+$/; say '' . ($1 ? "$1 " : '') . $2; }
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl use strict; use warnings; use 5.010; for (q(Name Vornamesip:0813893511@b2b.domain), q(0813893511sip:0813893511@b2b.domain)) { /(.*)?sip:(\d+)\@.+$/; say '' . ($1 eq $2 ? $1 : '') . $2; }
2017-11-22T08:10:52 reneeDas wird bei "George W. Bush" nicht klappen... ;-)
Guest payxOk, das wusste ich nicht ;-)2017-11-22T08:10:52 reneeDas wird bei "George W. Bush" nicht klappen... ;-)
Das war Absicht, den mag ich nämlich nicht. ;-)
2017-11-22T08:10:52 reneeCode (perl): (dl )say '' . ($1 eq $2 ? $1 : '') . $2;
say '' . ($1 eq $2 ? '' : "$1 ") . $2;