@@ -310,6 +310,77 @@ to get:
310310
311311---
312312
313+ <details >
314+ <summary ><strong >Filtering</strong ></summary >
315+
316+ Filtering can be done on one or more columns. All filters are applied with AND logic (all must match).
317+ Filters are applied before sorting.
318+
319+ ``` golang
320+ t.FilterBy ([]table.FilterBy {
321+ {Name: " Salary" , Operator: table.GreaterThan , Value: 2000 },
322+ {Name: " First Name" , Operator: table.Contains , Value: " on" },
323+ })
324+ ```
325+
326+ The ` Operator ` field in ` FilterBy ` supports various filtering operators:
327+ - ` Equal ` / ` NotEqual ` - Exact match
328+ - ` GreaterThan ` / ` GreaterThanOrEqual ` - Numeric comparisons
329+ - ` LessThan ` / ` LessThanOrEqual ` - Numeric comparisons
330+ - ` Contains ` / ` NotContains ` - String search
331+ - ` StartsWith ` / ` EndsWith ` - String prefix/suffix matching
332+ - ` RegexMatch ` / ` RegexNotMatch ` - Regular expression matching
333+
334+ You can make string comparisons case-insensitive by setting ` IgnoreCase: true ` :
335+ ``` golang
336+ t.FilterBy ([]table.FilterBy {
337+ {Name: " First Name" , Operator: table.Equal , Value: " JON" , IgnoreCase: true },
338+ })
339+ ```
340+
341+ For advanced filtering requirements, you can provide a custom filter function:
342+ ``` golang
343+ t.FilterBy ([]table.FilterBy {
344+ {
345+ Number: 2 ,
346+ CustomFilter: func (cellValue string ) bool {
347+ // Custom logic: include rows where first name length > 3
348+ return len (cellValue) > 3
349+ },
350+ },
351+ })
352+ ```
353+
354+ Example: Filter by salary and name
355+ ``` golang
356+ t := table.NewWriter ()
357+ t.AppendHeader (table.Row {" #" , " First Name" , " Last Name" , " Salary" })
358+ t.AppendRows ([]table.Row {
359+ {1 , " Arya" , " Stark" , 3000 },
360+ {20 , " Jon" , " Snow" , 2000 },
361+ {300 , " Tyrion" , " Lannister" , 5000 },
362+ {400 , " Sansa" , " Stark" , 2500 },
363+ })
364+ t.FilterBy ([]table.FilterBy {
365+ {Number: 4 , Operator: table.GreaterThan , Value: 2000 },
366+ {Number: 3 , Operator: table.Contains , Value: " Stark" },
367+ })
368+ t.Render ()
369+ ```
370+ to get:
371+ ```
372+ +-----+------------+-----------+--------+
373+ | # | FIRST NAME | LAST NAME | SALARY |
374+ +-----+------------+-----------+--------+
375+ | 1 | Arya | Stark | 3000 |
376+ | 400 | Sansa | Stark | 2500 |
377+ +-----+------------+-----------+--------+
378+ ```
379+
380+ </details >
381+
382+ ---
383+
313384<details >
314385<summary ><strong >Sorting</strong ></summary >
315386
0 commit comments