Blockly.Blocks['kjh'] = { init: function() { this.appendDummyInput().appendField('kjh'); this.setOutput(true, null); this.setColour(164); this.setTooltip(''); this.setHelpUrl(''); } }; Blockly.JavaScript['kjh'] = function(block) { var code = 'gdfnh'; return [code, Blockly.JavaScript.ORDER_NONE]; } <xml xmlns="http://www.w3.org/1999/xhtml"> <block type="variables_get" id="EaezE9)%*e^B{Olq7?Le" x="147" y="34"></block> </xml>
请问如何取这段字符串中的xml部分?非常感谢!
Regarding the problem of taking a piece of xml from a string? -PHP Chinese website Q&A-About the problem of fetching a piece of xml from a string? -PHP Chinese website Q&A
Let’s take a look and learn.
遇到这种我的一般做法是利用replace+正则来提取。
这里主要一个正则是关于这段文本如果有回车换行的情况,直接用.*并不能直接匹配,但可用[\s\S]*代替