Text lines intersection
text-lines-intersection · version 1.0.0 · Text · free, no key needed
Set intersection of two line sequences using exact line equality.
Use when you need to: text lines intersection · intersect lines · common lines.
Supported
- text lines intersection
- intersect lines
- common lines
Not supported
- multiset intersection
- trim
- case fold
- regex
Behavior
- Split on CR LF, LF, or CR. Do not treat other Unicode separators as line breaks.
- A trailing terminator does not create an extra empty line.
- Empty document -> zero lines, trailing_terminator false.
- A document that is only a terminator -> one empty line, trailing_terminator true.
- A document with no terminator -> last line kept, trailing_terminator false.
- Preserve empty lines in the middle.
- Output reconstruction uses LF. If the result has at least one line, append a trailing LF iff the selected window includes the original trailing terminator or includes a line that was followed by a separator in the source.
- No trimming, case folding, Unicode normalization, or locale rules.
- Treat each document as a set of exact line bodies (uniqueness inside a and b).
- Result is lines that occur in both a and b, in first-seen order from a, unique.
- Output trailing terminator follows a when the result is non-empty and a had a trailing terminator.
Input
a(string, required): max length 256000b(string, required): max length 256000
Output
text(string, required)lines_in_a(integer, required)lines_in_b(integer, required)lines_out(integer, required)
Limits
- max input bytes: 256000
- max lines: 10000
Example
Request input:
{
"a": "a\nb\na\nc\n",
"b": "c\nb\n"
}
Response:
{
"result": {
"text": "b\nc\n",
"lines_in_a": 4,
"lines_in_b": 2,
"lines_out": 2
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "text-lines-intersection",
"version": "1.0.0",
"input": {
"a": "a\nb\na\nc\n",
"b": "c\nb\n"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/text-lines-intersection/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":"a\nb\na\nc\n","b":"c\nb\n"}'
The machine-readable contract is at /v1/tools/text-lines-intersection/versions/1.0.0.
CLI
node cli.mjs run text-lines-intersection 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Text count: Count Unicode code points, UTF-16 code units, UTF-8 bytes, and lines.
- Text line diff: Diff two texts as line records, preserving each line terminator.
- Text lines chunk: Split parsed lines into consecutive chunks of size lines each.
- Text lines count: Count exact line multiplicities in first-seen order.
- Text lines difference: Set difference a minus b using exact line equality.
- Text lines head: Return the first n parsed lines with LF reconstruction.