List extractor by expression
Pick lines out of a list with a math expression where i is the line number — plus, minus, times, divide, modulo, parentheses and unary signs only, non-zero means a match, no eval involved, with a zero-based option and optional index labels.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Extracted lines
Only lines matching the expression are shown.
Paste a list and an expression to extract lines
Evaluated: 0 · Matched: 0 · Max index: 0
What this tool does
- Sample lines by rule — odd rows with i % 2, every third row with 1 - i % 3, and so on.
- Pick a slice of a long list by its line numbers, e.g. keep i / 3 when the value must equal 1 to take one line out of every three.
- Extract a regular subset of a long list without writing code or touching Excel.
Example
Input
a b c d e f g h i j
Output
b d f h j
With “every value must equal 1”, 1 - i % 2 keeps only the even lines.
Frequently asked questions
Which operators are supported?
Only `+ - * / % ( )`, unary signs, numbers and the variable i. There are no comparison operators (== is rejected), no functions and no power operator. To express a condition, write it as an expression that evaluates to 1 and switch the match rule to “must equal 1”.
Is i 1-based or 0-based?
1-based by default, matching “which line is this”. Switch “Meaning of i” to zero-based to think in array indices, where the first line has i = 0. Indexes are counted after blank lines are dropped.
Why does 1/2+1/2 match?
Because the result is exactly 1 — 0.5+0.5 is exact in double precision. Note that 0.1+0.2 gives 0.30000000000000004, so an “equals 1” test can be off by a tiny amount; prefer expressions that produce clean 0/1 values.
What happens when the expression is wrong?
An invalid expression (i +, i % 2 == 0, a function call, division by zero) reports an error immediately instead of returning a half-finished result. The expression is compiled once, before any line is evaluated.
Keywords:按规则抽取表达式筛选list expression行号公式数学表达式percent pick取奇数行取偶数行