-2
A
回答
0
"/\{\#(.*?)\#\}/g"
而且學習正則表達式這裏http://regex101.com/
編輯:
你分享一些你的代碼,因爲它工作得很好。 這裏是正則表達式
http://regex101.com/r/aC1fT2/1
的測試,在這裏它是在行動:
~
⚡⚡⚡ more test.php; php test.php
<?php
//The source code
$pattern = "/\{\#(.*?)\#\}/";
$test_string =
"
Lorem Ipsum is simply {#dummy#} text
of the printing and typesetting industry.
Lorem Ipsum has been the industry's {#standard#} dummy text
ever since the 1500s,
when an unknown printer took a galley of type
and scrambled it to make a type specimen book.
It has survived not only five centuries,
but also the leap into electronic typesetting,
remaining {#essentially unchanged#}.
It was popularised in the 1960s
with the release of Letraset sheets
containing Lorem Ipsum passages,
{#and more recently with desktop publishing software#}
like Aldus PageMaker including versions of Lorem Ipsum.
";
preg_match_all($pattern, $test_string, $matches);
print_r($matches);
?>
...
//The output
Array
(
[0] => Array
(
[0] => {#dummy#}
[1] => {#standard#}
[2] => {#essentially unchanged#}
[3] => {#and more recently with desktop publishing software#}
)
[1] => Array
(
[0] => dummy
[1] => standard
[2] => essentially unchanged
[3] => and more recently with desktop publishing software
)
)
+0
'{# 名稱:測試 文件名:測試1 日期:123 作者日期:測試 #}' – 2014-10-10 16:12:09
+0
我甚至不... 不這行得通? – ehwas 2014-10-10 16:58:34
相關問題
- 1. 正則表達式(的preg_match)
- 2. php preg_match正則表達式
- 3. PHP - 正則表達式(preg_match)
- 4. 正則表達式,preg_match
- 5. preg_match和正則表達式
- 6. 正則表達式preg_match字
- 7. 正則表達式preg_match PHP
- 8. php正則表達式preg_match
- 9. 正則表達式和preg_match()
- 10. PHP的preg_match和正則表達式的正則表達式
- 11. 帶正則表達式的Preg_match模式
- 12. 如何改變),這個正則表達式的preg_match(
- 13. findall與這個正則表達式匹配之間的困惑
- 14. 這三個正則表達式之間的區別是什麼
- 15. 這兩個正則表達式之間的區別?
- 16. 正則表達式匹配兩個表達式之間的線
- 17. PHP的preg_match()的正則表達式
- 18. 這是正確的正則表達式(eregi preg_match轉換)
- 19. preg_match /正則表達式格式需要
- 20. 用的preg_match正則表達式
- 21. sed將PHP的preg_match正則表達式
- 22. PHP中的正則表達式preg_match
- 23. 帶正則表達式的Preg_match?
- 24. PHP的preg_match - 正則表達式
- 25. PHP的preg_match和正則表達式
- 26. 正則表達式的preg_match()發出
- 27. PHP正則表達式幫助的preg_match
- 28. 正則表達式的preg_match用逗號
- 29. PHP的正則表達式preg_match故障
- 30. PHP,正則表達式和的preg_match
請發表您已經嘗試了什麼。 – MontrealDevOne 2014-10-09 17:06:07
我試着用str_replace函數,但不正確的做法 – 2017-05-06 15:56:49