Home  >  Article  >  Backend Development  >  这个正则如何写啊

这个正则如何写啊

WBOY
WBOYOriginal
2016-06-13 13:00:49972browse

这个正则怎么写啊?
0^50411^1^10^5.0000^1900-01-01^0^ 10 ^58^元/人^^^^友邦保险

$1^50411^1^20^5.0000^1900-01-01^0^ 20 ^59^元/人^^^^平安保险

$2^57777^1^60^50.0000^2012-12-19^633183^ 60 ^13^元/人^^^^AAAAAA

$3^57777^1^60^50.0000^2012-12-20^633183^ 60 ^13^元/人^^^^BBBBBB


这一串字符,

我想用  /\$\d/ 来作为正则分割  由 $1,$2,$3 分割开的,

但是这么写并不行!

然后再用 ^^^^ 分割每一个数组子元素,获得 友邦保险 ,平安保险 等这些名字

/\^\^\^\^/ 这么写也不行,好奇怪!
------解决方案--------------------

$s = <<< TXT<br />
0^50411^1^10^5.0000^1900-01-01^0^ 10 ^58^元/人^^^^友邦保险<br />
<br />
$1^50411^1^20^5.0000^1900-01-01^0^ 20 ^59^元/人^^^^平安保险<br />
<br />
$2^57777^1^60^50.0000^2012-12-19^633183^ 60 ^13^元/人^^^^AAAAAA<br />
<br />
$3^57777^1^60^50.0000^2012-12-20^633183^ 60 ^13^元/人^^^^BBBBBB<br />
TXT;<br />
preg_match_all('/[^^]+$/m', $s, $r);<br />
print_r($r);
Array
(
    [0] => Array
        (
            [0] => 友邦保险

            [1] => 平安保险

            [2] => AAAAAA

            [3] => BBBBBB
        )

)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn