Positional matchers are zero-width matchers that constrain where a pattern can match within the input. They produce no captured value and must be combined with other matchers such as LD, WORD, or IPADDR.
Positional matchers always refer to the absolute start or end of the input string, regardless of newlines. Use EOL to match line boundaries.
matchesPattern anchors the pattern to the entire input, so positional matchers like BOS and EOS are redundant here—the function already requires a full-input match. This is why the patterns on this page can often appear to work the same with or without the positional matcher. Their effect becomes relevant with functions that can match anywhere in the input, such as parseAll, where the position constraint is what limits where the pattern is allowed to match.
BOS (beginning of string) and BOF (beginning of file) match the position at the very start of the input.
BOS and BOF produce no output. They are positional anchors that constrain matching to the start of the input.
INFO:Use the following expression to check whether the input starts with INFO::
BOS 'INFO:' LD
| Description | input (string) | result (boolean) |
|---|---|---|
Starts with |
|
|
Starts with |
|
|
|
|
|
data record(input = "INFO: server started"),record(input = "DEBUG: handler invoked"),record(input = "Log entry - INFO: started")| fieldsAdd result = matchesPattern(input, "BOS 'INFO:' LD")
Given the following input:
input (string) |
|---|
|
Use the following expression to extract the first line:
BOS LD:header
header (string) |
|---|
|
data record(input = """"name","surname""Ned","Flanders""Homer","Simpson""Charles","Burns"""")| parse input, "BOS LD:header"
MOS (middle of string) and MOF (middle of file) match any position that is neither the start nor the end of the input. Because parse and matchesPattern work on the input as a whole, MOS is mainly used inside iterative matching with the parseAll function, where it restricts matches to positions other than the very start.
MOS and MOF produce no output. They are positional anchors that exclude matches at the start or end of the input.
ERROR in the middle of the inputUse the following expression to check whether ERROR appears in the middle of the input—neither at the start nor at the end:
LD MOS 'ERROR' MOS LD
| Description | input (string) | result (boolean) |
|---|---|---|
|
|
|
|
|
|
|
|
|
No |
|
|
data record(input = "Got ERROR while parsing"),record(input = "ERROR while parsing"),record(input = "Failed with ERROR"),record(input = "Operation succeeded")| fieldsAdd result = matchesPattern(input, "LD MOS 'ERROR' MOS LD")
Given the following input:
input (string) |
|---|
|
Use the following expression with parseAll to extract every line except the first one. MOS ensures the header line at position 0 is skipped:
MOS DQS:name ',' DQS:surname (EOL | EOS)
name (string) | surname (string) |
|---|---|
|
|
|
|
|
|
data record(input = """"name","surname""Ned","Flanders""Homer","Simpson""Charles","Burns"""")| fields rows = parseAll(input, "MOS DQS:name ',' DQS:surname (EOL | EOS)")
EOS (end of string) and EOF (end of file) match the position at the very end of the input. Use EOS with parse to require the matched portion to extend to the input's last character—without EOS, parse succeeds even when extra content follows the match. In matchesPattern, end-anchoring is implicit, so EOS is most useful with parse or inside alternations.
EOS and EOF produce no output. They are positional anchors that constrain matching to the end of the input.
OKUse the following expression to check whether the input ends with OK:
LD 'OK' EOS
| Description | input (string) | result (boolean) |
|---|---|---|
Ends with |
|
|
Ends with a different word |
|
|
|
|
|
data record(input = "Status: OK"),record(input = "Status: failed"),record(input = "OK then failed")| fieldsAdd result = matchesPattern(input, "LD 'OK' EOS")
Use the following expression to check whether each record ends with an IP address. The expression matches only when no content follows the IP:
LD IPADDR EOS
input (string) | result (boolean) |
|---|---|
|
|
|
|
|
|
data record(input = "userId=1246 ip=124.5.2.4"),record(input = "userId=441122 ip=75.52.12.1 status=error message='Login failed'"),record(input = "userId=753434 ip=4.4.3.2")| fieldsAdd result = matchesPattern(input, "LD IPADDR EOS")
EOSGiven the following input, which contains two IP addresses:
Log has 127.0.0.1 and ends with 156.34.11.23
Without EOS, the expression extracts the first IP found anywhere in the input:
LD IP:out
out (ip) |
|---|
|
data record(input = "Log has 127.0.0.1 and ends with 156.34.11.23")| parse input, "LD IP:out"