What does "contains" mean in text processing?

In text processing, "contains" refers to checking whether a specific sequence of characters (a substring) exists within a larger piece of text. This fundamental operation is used extensively in programming, data validation, and search functionality. Unlike exact matching, a contains check returns true as long as the substring appears anywhere in the text, regardless of its position.

The contains operation can be case-sensitive or case-insensitive depending on the requirements. Case-sensitive searches treat uppercase and lowercase letters as different characters, while case-insensitive searches ignore letter casing entirely. Additionally, advanced contains checks can verify not just the presence of a substring, but also how many times it appears.

Tool description

This tool validates whether a text string contains a specific substring, with configurable options for case sensitivity and minimum occurrence requirements. It provides both a pass/fail validation result and a count of how many times the substring appears in the text.

Examples

Basic substring check:

  • Input text: The quick brown fox jumps over the lazy dog
  • Search substring: fox
  • Result: ✓ Valid (1 occurrence found)

Case-insensitive search:

  • Input text: Hello World, hello universe
  • Search substring: hello
  • Ignore case: Yes
  • Result: ✓ Valid (2 occurrences found)

Minimum occurrences validation:

  • Input text: apple banana apple cherry apple
  • Search substring: apple
  • Minimum occurrences: 3
  • Result: ✓ Valid (3 occurrences found)

Failed validation:

  • Input text: JavaScript is awesome
  • Search substring: python
  • Result: ✗ Invalid (0 occurrences found)

Features

  • Substring validation — Instantly check if text contains a specific substring
  • Case sensitivity toggle — Option to ignore letter casing during search
  • Minimum occurrence threshold — Set required number of substring appearances for validation to pass
  • Occurrence counter — Displays exact count of how many times the substring appears
  • Real-time validation — Results update instantly as you type

Use cases

  • Form validation — Verify that user input contains required keywords, domains, or patterns before submission
  • Content moderation — Check if text contains specific words or phrases that need to be flagged or filtered
  • Data quality checks — Validate that imported data fields contain expected substrings or identifiers

Options explained

Option Description
Text to search The main text content where you want to find the substring
Search substring The specific text pattern you're looking for within the main text
Ignore case When enabled, treats "Hello" and "hello" as the same during search
Minimum occurrences The substring must appear at least this many times for validation to pass (default: 1)

How it works

The tool uses the validator.contains() function from the validator.js library to perform the validation. It searches through the input text looking for matches of the specified substring. When case-insensitive mode is enabled, both the input text and substring are converted to lowercase before comparison. The occurrence count is calculated by iterating through the text and counting non-overlapping matches of the substring.