联系表7的内容由正则表达式爆炸 [英] Contact Form 7 content explode by regular expressions
本文介绍了联系表7的内容由正则表达式爆炸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有从WP帖子获得的联系表7的内容。看起来像这样:
I have a contents of 'Contact Form 7' that I got from WP post. It looks something like this:
Your Name (required)
[text* your-name]
Your Email (required)
[email* your-email]
Subject
[text your-subject]
Your Message
[textarea your-message]
[submit "Send"]
我需要通过正则表达式将此内容分解为数组。在过程结束时,它应该看起来像这样:
I need to explode this content to an array by regular expressions. At the end of the process it should look like this:
$arr = array (
'text* your-name',
'email* your-email',
'text your-subject',
'textarea your-message',
'submit "Send"',
)
有人知道如何通过使用正则表达式或其他方式来实现吗?
谢谢:)
Does anyone have an idea how to do it by using regular expressions or any other way? Thanks :)
推荐答案
(?<=\[)([^\]]+)
尝试一下。捕获内容。请观看演示。
Try this.Grab the capture.See demo.
http://regex101.com/r/yP3iB0/ 8
$re = ""(?<=\\[)([^\\]]+)"";
$str = "Your Name (required)\n[text* your-name]\n\nYour Email (required)\n[email* your-email]\n\nSubject\n[text your-subject]\n\nYour Message\n[textarea your-message]\n\n[submit \"Send\"]";
preg_match_all($re, $str, $matches);
这篇关于联系表7的内容由正则表达式爆炸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文