## Grep File

`client.Beta.Retrieval.Grep(ctx, params) (*PaginatedCursorPost[BetaRetrievalGrepResponse], error)`

**post** `/api/v1/retrieval/files/grep`

Grep within a file's parsed content using a regex pattern.

### Parameters

- `params BetaRetrievalGrepParams`

  - `FileID param.Field[string]`

    Body param: ID of the file to grep.

  - `IndexID param.Field[string]`

    Body param: ID of the index the file belongs to.

  - `Pattern param.Field[string]`

    Body param: Regex pattern to search for.

  - `OrganizationID param.Field[string]`

    Query param

  - `ProjectID param.Field[string]`

    Query param

  - `ContextChars param.Field[int64]`

    Body param: Number of characters of context to include before and after the matched pattern in the content field of the response

  - `PageSize param.Field[int64]`

    Body param: The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum.

  - `PageToken param.Field[string]`

    Body param: A page token, received from a previous list call. Provide this to retrieve the subsequent page.

### Returns

- `type BetaRetrievalGrepResponse struct{…}`

  A single grep match within a file.

  - `Content string`

    Matched text content.

  - `EndChar int64`

    End character offset of the match.

  - `StartChar int64`

    Start character offset of the match.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/run-llama/llama-parse-go"
  "github.com/run-llama/llama-parse-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.Beta.Retrieval.Grep(context.TODO(), llamacloudprod.BetaRetrievalGrepParams{
    FileID: "file_id",
    IndexID: "idx-abc123",
    Pattern: "revenue|profit",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### Response

```json
{
  "items": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```
