You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Query] Support SPARQL XPath REGEX flags (x, q, s, m, i) and pattern matching #592
Implement full SPARQL 1.1 / XPath fn:matches flag support and pattern syntax compatibility for the REGEX built-in function.
Target Branch
feature/corese-next
Specification & Semantics
According to W3C SPARQL 1.1 Query (§17.4.3.14 REGEX) invoking XPath fn:matches:
Flag i: case-insensitive matching.
Flag s: dot-all mode (. matches newline characters).
Flag m: multiline mode (^ and $ match start/end of lines).
Flag x: extended whitespace and comments (whitespace within pattern is ignored, # marks comments until end of line).
Flag q: quote mode (pattern characters are treated literally without regex escaping).
Character classes and bracket expressions [] must conform to standard XML Schema / XPath regular expressions.
Technical Context & Implementation Notes
Flag translation:
In NativeExpressionEvaluator.java, map XPath flags to java.util.regex.Pattern flags:
i -> Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE
s -> Pattern.DOTALL
m -> Pattern.MULTILINE
x -> Pattern.COMMENTS
q -> Pattern.LITERAL
Compatibility handling:
Combinations such as iq or x with bracket expressions must evaluate properly against target literals.
Targeted W3C SPARQL 1.0 / 1.1 Test Cases
regex-query-003
regex-query-004
REGEX with [] expression
REGEX with the ignore spacing (x) option
REGEX with the ignore spacing (x) option with class expression
REGEX with the q option
REGEX with the iq option
Verification
Unit tests (corese-core): ./gradlew test --tests "fr.inria.corese.core.next.query.impl.sparql.bridge.NativeExpressionEvaluatorTest"
W3C conformance (corese-w3c): ./gradlew test --tests "fr.inria.corese.w3c.sparql10.Sparql10DynamicTest"
Acceptance Criteria
[ ] All standard XPath flags (i, s, m, x, q) are recognized and properly converted to Java regex flags.
[ ] Flag x correctly ignores whitespaces and ignores comments starting with #.
[ ] Flag q treats the pattern as a literal string.
[ ] The 7 targeted W3C SPARQL 1.0 regex tests pass.
[ ] 0 SonarLint issues and cognitive complexity < 15.
Activity
remiceres commentedon Sep 22, 2026
Resolved by #606. All 7 W3C SPARQL regex evaluation tests now pass.