gpt4 book ai didi

PHP Preg 匹配错误

转载 作者:搜寻专家 更新时间:2023-10-31 21:41:13 29 4
gpt4 key购买 nike

http://gskinner.com/RegExr/下面的正则表达式工作但不是在 PHP 中

(?>AB/HDR)(?:[^])*?(?=AB/HDR|RUN DATE|\z)

在 PHP 中是这样说的:

preg_match() [function.preg-match]: Unknown modifier '(' in E:\xampp\htdocs.....

没有太多的想法尝试了以下变体但没有结果

%(?>AB/HDR)(?:[^])*?(?=AB/HDR|RUN DATE|\z)% 
> result : Compilation failed: missing terminating ] for character class at offset 41

%(?>AB/HDR)(?:\[^])*?(?=AB/HDR|RUN DATE|\z)%
> result : 0 match which is incorrect

任何帮助将不胜感激!!!

测试数据

RUN DATE: 15FEB12                        F E D E R A L    E X P R E S S     C O R P O R A T I O N             PAGE:    1
RUN TIME: 09:36 INTERNATIONAL DETAIL MANIFEST REPORT: FEVIP093-R1
SEQUENCE: DN,ST,BT,BA,MB,BD,DV,RT,AWB OUTBOUND REQUEST BY ROUTE



AB/HDR : 4876 6218 1850 ORIG: SYD DEST: DAC ORIGIN CNTRY: AU EXPORT CNTRY: AU SHIP DATE: 14FEB12
CONSIGNEE ACCT : 000000000 PHONE : +88 02 8834304 SHIPPER ACCT : 141639668 PHONE : 0299978166
COMPANY: EASY FLY EXPRESS LTD COMPANY: INTERNATIONAL AIR PARTS
NAME: ADYET NAME: GREG FULLER
ADDRESS: HOUSE NO.4, 5TH FLOOR, ROAD NO.20 ADDRESS: 5A JUBILEE AVENUE
ADDRESS: UTTARA, SECTOR-3 ADDRESS:
CITY: DHAKA CITY: WARRIEWOOD
ST/PV: CNTRY: BD POSTAL: 1230 ST/PV: CNTRY: AU POSTAL: 2102
BROKER: PHONE: CITY: CNTRY: CUSTOMS ID NBR:
SVC: 0101 BILL-T/C: S BILL-D/T: S TTL PKGS: 1 TTL WGT: 0.5 K CURR: USD CUSTOMS VALUE: 90.00
MAWB: DESC: AIRCRAFT PARTS, 1 X FILTER

AB/HDR : 4926 0503 9651 ORIG: SYM DEST: DAC ORIGIN CNTRY: CN EXPORT CNTRY: CN SHIP DATE: 14FEB12 ECI
CONSIGNEE ACCT : 000000000 PHONE : 880-27701506-9 SHIPPER ACCT : 354519100 PHONE : 26501338-8004
COMPANY: HOP LUN BANGLADESH COMPANY: FINELINE(4403137628)
NAME: MR. EMRAN NAME: MISS WU
ADDRESS: BLDG NO. 3 (4 STORIED BLDG) ADDRESS: 3F BLDG D, HUICHAO INDUSTRIAL PAR
ADDRESS: DHAKA EXPORT PROCESSING ZONE ADDRESS: SECOND GUSHU ROAD XIXIANG TOWN,
CITY: GANAKBARI SAVAR DHAK CITY: BAOAN DIST SHENZHEN
ST/PV: CNTRY: BD POSTAL: 1349 ST/PV: CNTRY: CN POSTAL: 518102
BROKER: PHONE: CITY: CNTRY: CUSTOMS ID NBR:
SVC: 0101 BILL-T/C: O BILL-D/T: C TTL PKGS: 2 TTL WGT: 7.7 K CURR: USD CUSTOMS VALUE: 346.50
MAWB: DESC: PRICE TICKET L(4821100000)NO BRAND

CRN: 492605039662


RUN DATE: 15FEB12 F E D E R A L E X P R E S S C O R P O R A T I O N PAGE: 11
RUN TIME: 09:36 INTERNATIONAL DETAIL MANIFEST REPORT: FEVIP093-R1
SEQUENCE: DN,ST,BT,BA,MB,BD,DV,RT,AWB OUTBOUND REQUEST BY ROUTE

最佳答案

首先,这是不允许的

[^]

我已将其替换为 .。其次,您需要模式分隔符:

#(?>AB/HDR)(?:.)*?(?=AB/HDR|RUN DATE|\z)#

忘记了 点匹配所有修饰符:

#(?>AB/HDR)(?:.)*?(?=AB/HDR|RUN DATE|\Z)#s

关于PHP Preg 匹配错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10868891/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com