⭐ 0

Find in Text

Find a literal string or a /pattern/flags expression and list each hit with its line, index, and a short context.

🔒 Processed entirely in your browser — nothing you enter here is ever uploaded.

The result appears on this page after you run the tool. Nothing you enter is uploaded.

Processing... 0%
Reading text input
Analyzing text lines
Matching boundaries
Formulating output

Result

About this tool

Paste the text, type a query, and run the search. The case-sensitive box starts checked, so cat does not match Cat. The text is split on newline and each line is searched on its own. A query that does not start with a slash is a literal: regular-expression characters in it are escaped, then compiled with the g flag, or gi when the case box is cleared. A query that starts with a slash and has a later slash is compiled as a pattern. The flags are the characters after the last slash. If the case box is cleared and those flags do not already contain i, i is added. If the pattern does not compile, the search falls back to a literal of the whole query string.

The cat sat. searched for cat, with the case box left on, produces one hit. The report starts Found 1 matches: then Line 1: Match "cat" at index 4, and a context line. The index is the position on that line, starting at 0, so the c in cat is the fifth character. The context takes up to 30 characters before the match and 30 after it. A snippet that does not start at the beginning of the line is prefixed with three dots, and one that does not reach the end is suffixed with three dots. The cat sat. is short enough that the context is the whole line. A line with no hit is omitted. No hits at all produce the sentence No matches found.

The sentence-start and sentence-end boxes are off by default. Turn sentence start on and a hit is kept only when the trimmed text before it on that same line is empty or ends in a period, exclamation mark, or question mark. Sentence end keeps a hit only when the trimmed text after it on that line is empty or begins with one of those three marks. The checks do not look at the previous or next line. A match at the start of a line passes the start check. A match at the end of a line passes the end check. An empty query never searches. It writes Please enter a search query. A zero-length match cannot loop forever: if the expression does not move the scan index, the scanner steps one character. The result is text in the output box, not a highlighted copy of the original. There is no replace on this page. The replace page is separate, and its sentence checks look at the whole string rather than one line. Nothing is uploaded. A very long paste is still scanned in the browser, one line at a time.

Example. The text The cat sat. with the query cat and the case box left on reports Found 1 matches, Line 1: Match "cat" at index 4, and the whole short line as context.

Limit. Sentence-start and sentence-end tests look only at the current line. An empty query does not search. A pattern that fails to compile is searched as a literal.

Where is cat in The cat sat.?

Index 4 on line 1. The report line is Line 1: Match "cat" at index 4. Counting starts at 0. The context for that short line is the line itself, because the match is not more than 30 characters from either end.

How do I search with a regular expression?

Wrap the pattern in slashes and put flags after the closing slash. With the case box checked, those flags are used as written. Clear the case box and i is added if you did not include it. A pattern that does not compile is escaped and searched as literal text.

What does sentence start mean?

On this page it is per line. The hit is kept when the trimmed text before it on that line is empty or ends in . ! or ?. The previous line does not count. Sentence end uses the trimmed text after the hit on the same line.

What if nothing matches?

The output is No matches found. An empty query is different: Please enter a search query. The case box starts checked, so a capital letter that you did not type is a miss until you clear that box.