草庐IT

php - preg_match() : Compilation failed: character value in\x{} or\o{} is too large at offset 27 on line number 25

coder 2023-12-30 原文

我正在编写一些 PHP 代码。在此代码中,我在 for 循环中运行 for 循环以遍历数组,然后遍历数组中当前字符串中的字符。

然后我想对当前字符串执行 preg_match() 以查看它是否匹配相当长的 RegEx。

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000-}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/', $input[$i][$j])

但我不断收到以下错误:

WARNING preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 27 on line number 25

最佳答案

添加UTF-8解析,你不是UFT8模式。添加 u 参数。

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000-}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/u', $input[$i][$j]);

另外,我也想强调一下,你有一个错字。 \x{2000-} 应该是 \x{2000}\x{2000}-:

preg_match('/[ \f\n\r\t\v\x{00a0}\x{1680}\x{180e}\x{2000}\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]/u', $input[$i][$j]);

关于php - preg_match() : Compilation failed: character value in\x{} or\o{} is too large at offset 27 on line number 25,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32375531/

有关php - preg_match() : Compilation failed: character value in\x{} or\o{} is too large at offset 27 on line number 25的更多相关文章

  1. ruby - 为什么 `Symbol#match` 的行为与 `String#match` 和 `Regexp#match` 不同? - 2

    String#match和Regexp#match在匹配成功时返回一个MatchData:"".match(//)#=>#//.match("")#=>#//.match(:"")#=>#但是Symbol#match返回匹配位置(如String#=~)::"".match(//)#=>0为什么Symbol#match表现不同?有用例吗? 最佳答案 我将其报告为Ruby核心中的错误:https://bugs.ruby-lang.org/issues/11991.让我们看看他们会怎么说。更新被质疑的行为似乎是一个错误。似乎从Ruby2.

  2. ruby , `match' : invalid byte sequence in UTF-8 - 2

    我对UTF-8编码有一些问题。我在这里阅读了一些帖子,但它仍然无法正常工作。这是我的代码:#!/bin/envruby#encoding:utf-8defdeterminefile=File.open("/home/lala.txt")file.eachdo|line|puts(line)type=line.match(/DOG/)puts('aaaaa')iftype!=nilputs(type[0])breakendendend这是我文件的前3行:;?lalalalal60000065535-1362490443-0000006334-0000018467-0000000041en

  3. No loop matching the specified signature and casting was found for ufunc greater - 2

    目录报错信息np.greater学习临时解决方法:np.greater去掉dtype报错信息pipinstallnumpy==1.24报错代码:dda=np.cumsum(np.greater(counts,0),dtype=np.int32)print(dda)Noloopmatchingthespecifiedsignatureandcastingwasfoundforufuncgreaternp.greater学习1.函数功能:判断参数一是否大于参数二。2.参数介绍  arr1:第一个参数类似一个数组  arr2:第二个参数类似一个数组  out:返回值是bool类型或者是元素为bool

  4. ruby-on-rails - Rails 4 路由错误 : No Route Matches [POST] - 2

    我在学习Rails4时正在做一个小练习,但在尝试更新对象时遇到路由错误。我不断收到错误消息:没有路由匹配[POST]"/movies/1/edit"但看不到我的代码哪里不正确:我的电影_controller.rbclassMoviesController"Yourmoviewassaved!"elserender"new"endenddefedit@movie=Movie.find(params[:id])enddefupdate@movie=Movie.find(params[:id])if@movie.update_attributes(params[:movie])redirec

  5. ruby-on-rails - rails 引擎 : rake routes show its routes but on rspec execution "No route matches" is thrown - 2

    我正在尝试测试我的应用程序正在使用的引擎内部的Controller。规范不在引擎中,而是在应用程序本身中(我试图在引擎中进行测试,但也遇到了问题)。我的引擎有以下routes.rb:Revision::Engine.routes.drawdoresources:steps,only:[]docollection{get:first}endend引擎正常挂载在应用routes.rb上:mountRevision::Engine=>"revision"当我运行rakeroutes时,在最后一行我得到:RoutesforRevision::Engine:first_stepsGET/step

  6. ruby - 安装 RDoc 文档时出错 : incompatible encoding regexp match - 2

    上周,在一些gem安装或gem更新操作中,我收到了与这些类似的错误:ERROR:Whilegeneratingdocumentationforsinatra-1.3.1...MESSAGE:errorgeneratingC:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/doc/sinatra-1.3.1/rdoc/README_de_rdoc.html:incompatibleencodingregexpmatch(UTF-8regexpwithIBM437string)(Encoding::CompatibilityError)类似的:E

  7. ruby 正则表达式 : ^ matches start of line even without m modifier? - 2

    ruby1.8.7。我正在使用带有^的正则表达式来匹配字符串开头的模式。问题是,如果在字符串中任何行的开头找到模式,它仍然匹配。如果我使用“m”修饰符但我没有使用,这是我期望的行为:$irbirb(main):001:0>str="hello\ngoodbye"=>"hello\ngoodbye"irb(main):002:0>putsstrhellogoodbye=>nilirb(main):004:0>str=~/^goodbye/=>6我在这里做错了什么? 最佳答案 行首:^行尾:$字符串的开头:\A字符串结尾:\z

  8. ruby - 模式匹配时 =~ 和 match() 有什么区别? - 2

    我正在使用Ruby1.9.3。我在玩一些模式,发现了一些有趣的东西:示例1:irb(main):001:0>/hay/=~'haystack'=>0irb(main):003:0>/st/=~'haystack'=>3示例2:irb(main):002:0>/hay/.match('haystack')=>#irb(main):004:0>/st/.match('haystack')=>#=~返回其第一个匹配项的第一个位置,而match返回模式。除此之外,=~和match()还有什么区别吗?执行时间差(根据@Casper)irb(main):005:0>quickbm(10000000

  9. ruby-on-rails - 在 Rails 3 中使用 current_page 时为 "No routes matches" - 2

    有没有人遇到过使用current_page时路由神秘地变得无法检测到?在Rails3中?即使使用包含路由、View和Controller的完全生成的脚手架,我也会收到“无路由匹配”错误。代码如下:ifcurrent_page?(:controller=>'users',:action=>"show")如果我向routes.rb添加一个“匹配”命令,它工作正常,但如果资源已经创建,为什么我需要这样做呢?我错过了什么? 最佳答案 如果你只是想测试当前的Controller,你可以这样做:ifparams[:controller]=='u

  10. ruby-on-rails - 验证失败 : Upload file has an extension that does not match its contents - 2

    我正在使用回形针gem上传文件。我的回形针gem版本是paperclip-4.1.1。上传文件时抛出Validationfailed:Uploadfilehasanextensionthatdoesnotmatchitscontents.我正在尝试上传xlsx文件。而且我已经在模型content_type中提到了这一点。validates_attachment_content_type:upload_file,:content_type=>%w(application/mswordapplication/vnd.ms-officeapplication/vnd.ms-excelappl

随机推荐