--- id: luhn title: luhn Search Operator sidebar_label: luhn description: Use the luhn operator to validate potential credit card numbers in log messages using Luhn's algorithm. slug: /help/docs/search/search-query-language/search-operators/luhn/ canonical: https://www.sumologic.com/help/docs/search/search-query-language/search-operators/luhn/ --- import useBaseUrl from '@docusaurus/useBaseUrl'; The `luhn` operator uses Luhn’s algorithm to check message logs for strings of numbers that may be credit card numbers and then validates them. It takes a string as an input, strips out all characters that are not numerals, and checks if the resulting string is a valid credit card number, returning true or false accordingly. ## Syntax `luhn() [as ]` `luhn("") [as ]` ## Examples ### Identify and verify credit card numbers in message logs Use the following query to identify credit card numbers in message logs, and verify them using the Luhn operator: ```sumo | parse regex "(?\d{4}-\d{4}-\d{4}-\d{4})" nodrop | parse regex "(?\d{4}\s\d{4}\s\d{4}\s\d{4})" nodrop | parse regex "(?\d{16})" nodrop | if (luhn(maybecc), true, false) as valid ``` which provides results such as: Operator example ### Search for and verify a specific credit card number Use the following query to search for a specific credit card number and verify it using the Luhn operator: ```sumo *| "6666-7777-6666-8888" as b | luhn(b) as d ``` It would provide the following results: Operator example