" " (regular
experssions). ?
-
, .
,
,
, .
.
PHP
(RE):
ereg(); ereg_replace(); eregi(); ereg_replacei(); split();
i
, . ,
, split().
: array split(string pattern, string string, int
[limit]);. pattern ().
RE, string.
, ,
.
: (),
, pattern. ,
, : ,
. "" .
,
,
( ).
RE.
, *. .
- .
,
" *" (, - ) -
.
,
0 .
, PHP RE:
$str = "test, one, to, sree";
$regs = split(", *",$str);
for ($i = 0; $i <= count($regs)-1; $i++) {
echo $i," : ",$regs[$i];
}
:
0 : test 1 : one 2 : to 3 : sree
, $str : "test, one, to, sree",
: "test,one,to,sree", :
"test,one, to, sree".
.
.
$HTTP_USER-AGENT, Internet Explorer.
:
Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
.
"MSIE" ,
. ? RE. MSIE ([^;]+).
, .
? ,
( - ). -
,
. ^ - . ..
[^;], " ,
". + ,
( ;) 1 ( ).
.
.
RE MSIE ([^;]+) , "
, ,
MSIE ".
.
ereg() ( eregi()).
: int ereg(string pattern, string string, array [regs]);.
pattern , string - ,
regs ,
. ( 0)
,
pattern. , pattern
, false ,
.
:
ereg("MSIE ([^;]+)",$HTTP_USER_AGENT,$regs); echo "$HTTP_USER_AGENT : $HTTP_USER_AGENT
"; echo "VERSION : $regs[1]";
:
$HTTP_USER_AGENT : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) VERSION : 6.0