master
yaml 49 lines 1.23 KB
Raw
1 # Test PCRE2 named capture groups
2 pattern: "(?P<date>\\d{4}-\\d{2}-\\d{2})\\s+(?P<time>\\d{2}:\\d{2}:\\d{2})\\s+\\[(?P<thread>\\w+)\\]\\s+(?P<class>[\\w\\.]+)\\s+-\\s+(?P<message>.*)"
3
4 rewrite:
5 # Test referencing named groups in replacements
6 - key: TIMESTAMP
7 value: "${DATE}T${TIME}Z"
8 inject: yes
9
10 - key: THREAD_INFO
11 value: "Thread ${THREAD} at ${TIME}"
12 inject: yes
13
14 # Test nested group references
15 - key: MESSAGE
16 match: "(?P<action>\\w+)\\s+(?P<object>\\w+)\\s+(?P<id>\\d+)"
17 value: "Action=${action}, Object=${object}, ID=${id}"
18
19 # Test numeric group references alongside named
20 - key: SUMMARY
21 match: "(\\w+)\\s+(?P<target>\\w+)"
22 value: "${1} performed on ${target}"
23 inject: yes
24
25 # Test conditional matching with groups
26 - key: ERROR_CODE
27 match: "error\\s+(?P<code>E\\d{4})"
28 value: "${code}"
29 inject: yes
30
31 - key: WARNING_CODE
32 match: "warning\\s+(?P<code>W\\d{4})"
33 value: "${code}"
34 inject: yes
35
36 # Test group in match but not in replacement
37 - key: HAS_ERROR
38 match: "(?P<err>error|exception|fail)"
39 value: "true"
40 inject: yes
41
42 # Test invalid group reference
43 - key: INVALID_GROUP
44 value: "${nonexistent_group}"
45 inject: yes
46
47 filter:
48 include: ".*"
49 exclude: "^$"