Php Can';t让preg_replace删除一些号码
我有一个字符串,我使用Php Can';t让preg_replace删除一些号码,php,xml,regex,preg-replace,Php,Xml,Regex,Preg Replace,我有一个字符串,我使用\uu getLastResponse函数从Web服务的SoapClient对象上提取了该字符串 这个字符串的格式是XML文档,只是它的开头有一些不必要的数字,我需要先删除这些数字,然后才能将其解析为XML 我编写了一个preg\u replace函数来删除这些数字,但它不起作用;谁能解释一下原因吗 以下是相关代码: $string = $search_client->__getLastResponse(); $string = preg_replace('/\A^
\uu getLastResponse
函数从Web服务的SoapClient
对象上提取了该字符串
这个字符串的格式是XML文档,只是它的开头有一些不必要的数字,我需要先删除这些数字,然后才能将其解析为XML
我编写了一个preg\u replace
函数来删除这些数字,但它不起作用;谁能解释一下原因吗
以下是相关代码:
$string = $search_client->__getLastResponse();
$string = preg_replace('/\A^\d+\', '', $string);
初始字符串以
234682374643开头,在\A
之后有一个额外的^
。像这样使用它:
$string = preg_replace('/\A\d+/', '', $string);
在\A
之后有一个额外的^
。像这样使用它:
$string = preg_replace('/\A\d+/', '', $string);
在\A
之后有一个额外的^
。像这样使用它:
$string = preg_replace('/\A\d+/', '', $string);
在\A
之后有一个额外的^
。像这样使用它:
$string = preg_replace('/\A\d+/', '', $string);
删除\A
$re = "/^\\d+/";
$str = "234682374643<records xmlns=\"http://scien...</records>";
$subst = '';
$result = preg_replace($re, $subst, $str);
$re=“/^\\d+/”;
$str=“234682374643删除\A
$re = "/^\\d+/";
$str = "234682374643<records xmlns=\"http://scien...</records>";
$subst = '';
$result = preg_replace($re, $subst, $str);
$re=“/^\\d+/”;
$str=“234682374643删除\A
$re = "/^\\d+/";
$str = "234682374643<records xmlns=\"http://scien...</records>";
$subst = '';
$result = preg_replace($re, $subst, $str);
$re=“/^\\d+/”;
$str=“234682374643删除\A
$re = "/^\\d+/";
$str = "234682374643<records xmlns=\"http://scien...</records>";
$subst = '';
$result = preg_replace($re, $subst, $str);
$re=“/^\\d+/”;
$str=“234682374643并执行相同的操作(主题开始),类似于\Z
和$
(主题结束)
同时拥有\A
和^
会破坏匹配
您的分隔符也处于禁用状态
尝试:
并执行相同的操作(主题开始),类似于\Z
和$
(主题结束)
同时拥有\A
和^
会破坏匹配
您的分隔符也处于禁用状态
尝试:
并执行相同的操作(主题开始),类似于\Z
和$
(主题结束)
同时拥有\A
和^
会破坏匹配
您的分隔符也处于禁用状态
尝试:
并执行相同的操作(主题开始),类似于\Z
和$
(主题结束)
同时拥有\A
和^
会破坏匹配
您的分隔符也处于禁用状态
尝试:
谢谢大家的帮助
当我运行Halcyon发布的测试时发现了为什么会发生这种情况,他建议输入可能不像我想的那样。事实证明,无论何时我print\u r
或var\u dump
或任何\u getLastResponse
都只是显示值,并遗漏了字符串前面出现的一组标记,即:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchResponse xmlns:ns2="http://woksearch.v3.wokmws.thomsonreuters.com"><return><queryId>1</queryId><recordsFound>3670</recordsFound><recordsSearched>38802522</recordsSearched><records>... etc...</records>
1367038802522。。。等
这是实际返回的内容,而不是显示的1367038802522
前缀。如您所见,这些数字是上面标记中的所有值。我通过应用htmlspecialchars($search\u client->\u getLastResponse())得到了这个输出代码>以显示这些以前“隐藏”的字段
但奇怪的是,我不知道它为什么会这样做,因为在
标记之后,所有内容都会正确显示,之后所有打开的标记(感谢大家的帮助
当我运行Halcyon发布的测试时发现了为什么会发生这种情况,他建议输入可能不是我想的那样。结果表明,每当我print\u r
或var\u dump
或任何\u getLastResponse
的时候,它只是显示了值,并且遗漏了在st之前出现的一堆标记环,即:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchResponse xmlns:ns2="http://woksearch.v3.wokmws.thomsonreuters.com"><return><queryId>1</queryId><recordsFound>3670</recordsFound><recordsSearched>38802522</recordsSearched><records>... etc...</records>
1367038802522…等。。。
这是实际返回的值,而不是显示的1367038802522
前缀。正如您所看到的,这些数字都是上面标记中的值。我通过应用htmlspecialchars($search\u client->\uu getLastResponse());
来显示这些以前“隐藏”的字段,得到了这个输出
但奇怪的是,我不知道它为什么会这样做,因为在
标记之后,所有内容都会正确显示,之后所有打开的标记(感谢大家的帮助
当我运行Halcyon发布的测试时发现了为什么会发生这种情况,他建议输入可能不是我想的那样。结果表明,每当我print\u r
或var\u dump
或任何\u getLastResponse
的时候,它只是显示了值,并且遗漏了在st之前出现的一堆标记环,即:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchResponse xmlns:ns2="http://woksearch.v3.wokmws.thomsonreuters.com"><return><queryId>1</queryId><recordsFound>3670</recordsFound><recordsSearched>38802522</recordsSearched><records>... etc...</records>
1367038802522…等。。。
这是实际返回的值,而不是显示的1367038802522
前缀。正如您所看到的,这些数字都是上面标记中的值。我通过应用htmlspecialchars($search\u client->\uu getLastResponse());
来显示这些以前“隐藏”的字段,得到了这个输出
但奇怪的是,我不知道它为什么会这样做,因为在
标记之后,所有内容都会正确显示,之后所有打开的标记(感谢大家的帮助
当我运行Halcyon发布的测试时发现了为什么会发生这种情况,他建议输入可能不是我想的那样。结果表明,每当我print\u r
或var\u dump
或任何\u getLastResponse
的时候,它只是显示了值,并且遗漏了在st之前出现的一堆标记环,即:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchResponse xmlns:ns2="http://woksearch.v3.wokmws.thomsonreuters.com"><return><queryId>1</queryId><recordsFound>3670</recordsFound><recordsSearched>38802522</recordsSearched><records>... etc...</records>
1367038802522…等。。。
这是实际返回的值,而不是显示的1367038802522
前缀。正如您所看到的,这些数字都是上面标记中的值。我通过应用htmlspecialchars($search\u client->\uu getLastResponse());
来显示这些以前“隐藏”的字段,得到了这个输出
但奇怪的是,我不确定它为什么会这样做,因为在
标记之后,所有的内容都会正确显示,然后所有的开始标记(修改器在哪里?为什么