【问题标题】:Error in lookahead function前瞻功能错误
【发布时间】:2015-11-30 09:45:46
【问题描述】:

我有这个可变数据:

87||2|#88||3|#209|||#89||1|51#152|||#41||1|#4||1|#3||1|117#20|||#13|53,36|4|#17|7 50|1|#23||1|50014#15|||Condominiale#19||1|Parcheggio condominiale#150|||#24|||86#36|||50032#37|||94`



function caratteristiche1($title) {
  $input = "$title";
  $new_array = preg_match('/(\d+(?=#88||))/', $input);
  print_r($new_array);
}
`

我不明白错误在哪里。它总是报告 1,而不是

之后的数字
#88||...

【问题讨论】:

  • 请阅读 preg_match 的返回值。还。 $input = "$title"; - 不要那样做。
  • 另外,添加你想要的函数行为。
  • 感谢您的回答。
  • 好的,但是输入是可变的,那么在这种情况下我要写什么呢?行为呢?很抱歉,这是我第一次使用前瞻功能...提前致谢!
  • 似乎很不清楚。你想在这里实现什么

标签: php arrays function lookahead


【解决方案1】:

你需要转义那些||字符,它们在正则表达式中有特殊含义:http://php.net/manual/en/regexp.reference.meta.php

【讨论】:

  • 我知道,但我的数据中有这些......如何解释我需要的是在那两个管道之后?
  • 在正则表达式中转义管道,而不是在数据中!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-22
  • 2012-12-15
  • 1970-01-01
相关资源
最近更新 更多