S
S
Sergey2016-01-22 22:30:38
PHP
Sergey, 2016-01-22 22:30:38

Regulars - an optional "stop" character?

Chet I was tired. In general, there is a line like

text: texttext;text;var=abc;text

So, she could be
text: texttext;text;var=abc

The task is to pull out abc, regardless of whether there is a ; or not. Chet I can't.
I tried like this
'/^text: .*;var=(.*)[;|$]/im'

But I'm doing something wrong.
Here)
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 192.168.42.60:5060;received=37.29.41.213;rport=32292;branch=z9hG4bK-402014---1df3cefc
Call-ID: 6c3c92bdb3060bedcdb2a409b90eac96

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OVK2015, 2016-01-22
@r3l0c

$string = 'text: texttext;text;var=abc';//'text: texttext;text;var=abc;text';
$regExpWrapper = "/(?:var=)(.*?)(?:;|$)/";
preg_match($regExpWrapper, $string, $matches);
print_r($matches);

Your first group

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question