such as the article below
1111111
2222222
33333333
4444444
55555555
66666666
7777777
Match out
1111111
In the
And the last paragraph
7777777
Of
How do you get it?
Reply to discussion (solution)
Preg_match_all ('/^
. +<\/p>|
. +<\/p>$/u ', $s, $m);
Preg_match_all ('/^
. +<\/p>|
. +<\/p>$/u ', $s, $m);
This matches the whole paragraph.
All I want is a
Preg_match_all ('/^
. + (<\/p>) |
. + (<\/p>) $/u ', $s, $m);
$s =<<< TXT1111111
2222222
33333333
4444444
55555555
66666666
7777777
Txt;preg_match (' # ' ().+(
) #s ', $s, $r);p Rint_r ($r);
Array
(
[0] = =
2222222
33333333
4444444
55555555
66666666
7777777
[1] = =
[2] = =
)
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Don't use the regular.
11111112222222
33333333
4444444
55555555
66666666
7777777
';p rint strlen ($s);p rint stripos ($s, '');p rint strripos ($s, '
');? > Running results: 11310109
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
Actually, I want the first paragraph. Append some text, and the last paragraph to append some text
$s =<<< TXT1111111
2222222
33333333
4444444
55555555
66666666
7777777
Txt;echo preg_replace (' # ()(.+)(
) #s ', ' $1aaa$2$3bbb ', $s);
1111111
Aaa
2222222
33333333
4444444
55555555
66666666
7777777
Bbb
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
Actually, I want the first paragraph. Append some text, and the last paragraph to append some text
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
Actually, I want the first paragraph. Append some text, and the last paragraph to append some text
can also use this Ah, came to two '
' Position, segmentation the word and add the text you want to add.
But if the string itself is large, this is not very efficient.
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
Actually, I want the first paragraph. Append some text, and the last paragraph to append some text
can also use this Ah, came to two '
' Position, segmentation the word and add the text you want to add.
But if the string itself is large, this is not very efficient.
No need to cut, find the location and replace it directly.
11111112222222
33333333
4444444
55555555
66666666
7777777
';p rint strlen ($s); $find = ''; $find _len = 4; //
Length $s = substr_replace ($s, $find. " The first P ", Stripos ($s, '
'), $find _len); $s = substr_replace ($s, $find. " Last P ", Strripos ($s, '
'), $find _len);p rint $s;
If you just want to match
, you can use the regular.
PHP5, no one should use PHP4 now ...
$str = '1111111
2222222
33333333
4444444
55555555
66666666
7777777
'; $fp = Stripos ($str, '$first = substr ($str, $FP, 4); $ep = Stripos ($str, '
$end = substr ($str, $EP, 4);
Wrongly written, $ep = Strripos ($str, '
');
The upstairs brothers and I want to be the same.
Actually, I want the first paragraph. Append some text, and the last paragraph to append some text
can also use this Ah, came to two '
' Position, segmentation the word and add the text you want to add.
But if the string itself is large, this is not very efficient.
No need to cut, find the location and replace it directly.
11111112222222
33333333
4444444
55555555
66666666
7777777
';p rint strlen ($s); $find = ''; $find _len = 4; //
Length $s = substr_replace ($s, $find. " The first P ", Stripos ($s, '
'), $find _len); $s = substr_replace ($s, $find. " Last P ", Strripos ($s, '
'), $find _len);p rint $s;
This can