Regex insertion

S

sil

I need a regex of sorts that will replace ONLY the line:
P-Asserted-Identity: <sip:+$fU@$tU;user=phone>

with:
P-Asserted-Identity: <sip:[email protected]:5060> (from line 1)

Here is my data:

f:"Operations"<sip:
[email protected]:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:[email protected]>
m:<sip:[email protected]:5060;transport=udp>
i:[email protected]
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:+$fU@$tU;user=phone>

1 will always start with "f:"

New packet should read:

f:"Operations"<sip:
[email protected]:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:[email protected]>
m:<sip:[email protected]:5060;transport=udp>
i:[email protected]
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:[email protected]:5060>


#!/usr/bin/perl

my $sipPacket = 1;
my @packetData = '';

while ( my $line = <> ) {

if ( $line =~ m/^From: <sip.*/ ) {

if ( $sipPacket < 1 ){
pwnPacket(@packetData);
@packetData = '';
}

$sipPacket--;
next;
}

push @packetData, $line;

}

sub pwnPacket {
if ($_[1] =~ /From: <sip.*)(@)(.*)/) {

# Confusion seeps in... How do I insert it into the 13 field...
print "From: <sip:\1\2\3\r\nP-Asserted-
Identity:";


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top