I think you need the scan to terminate on the ) symbol by adding a $ to the
end of your pattern, e.g. ".+\(.+\)$"

On Thu, Apr 17, 2025 at 2:57 PM Mark Kozak <mark.ko...@adeptus-cs.com>
wrote:

> Hello folks.
>
>
>
> I am reaching out for a sanity check please.
>
> I am seeing a regular expression behavior that was driving me mad, but may
> actually be a bug?
>
>
>
> The example below is a simplified version for illustration:
>
>
>
> The goal is to check that a line of text starts with a string and ends
> with another string in parenthesis.
>
> Using the following data and subsequent schema, only the first line should
> pass validation. So I expect to see 5  validation failures. However only
> the last line is failed.
>
> Then just to keep things interesting, copy the first line to the end of
> the file, and then there are no validation failures at all.
>
> It appears that the assertion is being checked against only the last
> element in the sequence. Is that the intended behavior?
>
> I have tried this with 3.6 and 3.9 and get the same results both times.
>
>
>
> aaa(111)
>
> bbb
>
> (222)
>
> ccc(333)XXX
>
> ()
>
> (444)
>
>
>
>
>
>   <element name="sample">
>
>     <complexType>
>
>       <sequence dfdl:separator="%NL;" >
>
>         <element name="line" dfdl:lengthKind="delimited" type="xs:string"
> dfdl:occursCountKind="implicit" maxOccurs="unbounded" >
>
>             <annotation>
>
>                 <appinfo source="http://www.ogf.org/dfdl/";>
>
>                     <dfdl:assert testKind="pattern"
> failureType="recoverableError"
>
>                         testPattern=".+\(.+\)" />
>
>                 </appinfo>
>
>             </annotation>
>
>         </element>
>
>       </sequence>
>
>     </complexType>
>
>   </element>
>
>
>
>
>
> Thank you for the help.
>
>
>
> Mark Kozak
>
> Director of Engineering
>
> Adeptus Cyber Solutions
>
> Adeptus-CS.com
>
>
>

Reply via email to