Regex for Bot User Agent
Regex Pattern
(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\bDetects common bot/crawler User-Agent keywords
Quick Answer
The regex pattern for bot user agent is `(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\b`. Detects common bot/crawler User-Agent keywords. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.
Test Examples
| Input | Result |
|---|---|
| Googlebot/2.1 | ✓ Matches |
| Bingbot/2.0 | ✓ Matches |
| Slurp/3.0 | ✓ Matches |
| facebookexternalhit/1.1 spider | ✓ Matches |
| Mozilla/5.0 Chrome | ✗ No match |
| curl/7.68.0 | ✗ No match |
| MyApp/1.0 | ✗ No match |
Code Examples
javascript
const regex = /(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\b/; const isValid = regex.test(value);
python
import re
pattern = r'(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\b'
if re.match(pattern, value):
print("valid")ruby
pattern = /(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\b/ if value =~ pattern puts "valid" end
php
if (preg_match('/(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\b/', $value)) {
echo "valid";
}java
String pattern = "(?:bot|crawl|spider|slurp|fetch|archiv)(?:er)?\\b"; boolean isValid = value.matches(pattern);
Frequently Asked Questions
Related Regex Patterns
Subdomain Extraction
Extracts the subdomain from a URL or domain name
Protocol Detection
Detects and captures the protocol from a URL
Port Number
Extracts port number from a URL or host string
Query Parameter
Extracts key-value pairs from URL query strings
HTTP vs HTTPS URL
Matches HTTP or HTTPS URLs and captures the protocol
Data URL
Matches data: URL scheme with optional MIME type and base64 encoding