我想在suche代码中捕获所有出现的“对象”:
object InvalidFilterField3: TUNIField
FieldType = uftString
FieldName = 'PRI_SERIAL'
Caption = sdfgsdfgsdfg
Category = sdfgsdfgsdfgsdfg
Opers = [opEqual, opLike, opInList, opIsNull, opIsNotNull]
DefaultOper = opLike
FieldIndex = 0
end
object UNIField1: TUNIField
FieldType = uftDate
FieldName = 'PRI_DT'
Caption = sdfgsdfgsdfg
Category = asdfasdfasdfasdf
Opers = [opEqual, opNotEqual, opLarger, opSmaller, opEqualOrLarger, opEqualOrSmaller, opBetween, opIsNull, opIsNotNull, opIn]
DefaultOper = opEqual
FieldIndex = 1
end
认为必须是/object(.*)end/m
,但它不是=(
答案 0 :(得分:3)
你需要将dotall修饰符( s )传递给模式告诉PCRE一个点意味着任何(包括换行符)和ungreedy修饰符(< strong> U ,更多关于the PHP manual上的贪婪和修饰符):
preg_match_all('!object(.*)end!sU', $string, $matches);
print_r($matches);