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

这个正则如何写啊

WBOY
Release: 2016-06-13 13:00:49
Original
1023 people have browsed it

这个正则怎么写啊?
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);
Copy after login
Array
(
    [0] => Array
        (
            [0] => 友邦保险

            [1] => 平安保险

            [2] => AAAAAA

            [3] => BBBBBB
        )

)

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template