[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-571359-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-571359-en":127},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","regex-cheat-sheet","Regex Cheat Sheet","","A compact reference for regular-expression syntax and Java regex usage, covering character classes (including negation, ranges, union, intersection, and subtraction) as well as predefined classes like digits, whitespace, and word characters. It summarizes boundary anchors and key pattern flags for case-insensitive, comments, multiline, and UNIX line behavior. It also lists essential Java API methods for compiling patterns, matching, splitting, quoting, and using predicates, plus matcher operations and common quantifiers and grouping/backreferences.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/general/","General",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/regex-cheat-sheet/571359/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/regex-cheat-sheet/571359.png","ImageObject",442,249,{"name":42,"@type":43},"dbqoiu","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",7,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"How do I define a character class that matches anything except specific characters in Java regex?","Question",{"text":63,"@type":64},"Use negation with square brackets, for example [^abc] to match everything except a, b, or c.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"What do the anchors ^ and $ mean in a regex pattern?",{"text":68,"@type":64},"^ matches the beginning of a line, and $ matches the end of a line, helping restrict where a match can occur.",{"name":70,"@type":61,"acceptedAnswer":71},"How are quantifiers like ?, *, +, and {n,m} used to control match length?",{"text":72,"@type":64},"Use X? for zero or one, X* for zero or more, X+ for one or more, and X{n,m} for at least n and at most m occurrences; greedy, reluctant, and possessive variants change how the engine chooses matches.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},571359,1792086981,{"code":4,"msg":82,"data":83},"success",[84,89,94,99,104,109,114,119,124],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":86,"show_sort_weight":87,"slug":88},11,"Presentations",90,"presentations",{"id":90,"doc_module":22,"doc_module_name":25,"category_name":91,"show_sort_weight":92,"slug":93},12,"Resumes",80,"resumes",{"id":95,"doc_module":22,"doc_module_name":25,"category_name":96,"show_sort_weight":97,"slug":98},14,"Invoices",70,"invoices",{"id":100,"doc_module":22,"doc_module_name":25,"category_name":101,"show_sort_weight":102,"slug":103},15,"Posters",60,"posters",{"id":105,"doc_module":22,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},16,"Social Media",50,"social-media",{"id":110,"doc_module":22,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},17,"Forms",40,"forms",{"id":115,"doc_module":22,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},18,"Letters",30,"letters",{"id":120,"doc_module":22,"doc_module_name":25,"category_name":121,"show_sort_weight":122,"slug":123},21,"Paper Templates",5,"papers-templates",{"id":125,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":4,"slug":126},158,"general-158",{"code":4,"msg":82,"data":128},{"doc_id":79,"user_id":129,"nickname":42,"user_avatar":130,"doc_module":22,"category_id":125,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":22,"language":136,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":12,"update_tm":140,"read_time":4},3985747862462,"https://ap-avatar.wpscdn.com/davatar_3d24733baf745e90a7e4bdd5f77d97b2","Regex Cheat Sheet    \nCHARACTER CLASSES  \n[abc] Matches a or b, or c.  \n[^abc] Negation, matches everything except a, b, or c.[a-c] Range, matches a or b, or c.  \n[a-c[f-h]] Union, matches a, b, c, f, g, h.  \n[a-c&&[b-c]] Intersection, matches b or c.  \n[a-c&&[^b-c]] Subtraction, matches a.  \nPREDEFINED CHARACTER CLASSES  \n. Any character.\\d A digit: [0-9]\\D A non-digit: [^0-9]  \n\\s A whitespace character: [ \\t\\n\\x0B\\f\\r]  \n\\S A non-whitespace character: [^\\s]  \n\\w A word character: [a-zA-Z_0-9]  \n\\W A non-word character: [^\\w]  \nBOUNDARY MATCHES  \n^ The beginning of a line.  \n$ The end of a line.  \n\\b A word boundary.  \n\\B A non-word boundary.  \n\\A The beginning of the input.  \n\\G The end of the previous match.  \n\\Z The end of the input but for the final terminator, if any.\\z The end of the input.  \nPATTERN FLAGS  \nPattern.CASE  INSENSITIVE  \nEnables case-insensitive matching.  \nPattern.COMMENTS  \nWhitespace and comments starting with \\# are ignored until the end of a line.  \nPattern .MULTILINE  \nOne expression can match multiple lines.  \nPattern .UNIX LINES  \nOnly the '\\n' line terminator is recognized in the behavior of ., ^, and $ .  \nUSEFUL JAVA CLASSES & METHODS  \nPATTERN  \nA pattern is a compiler representation of a regular expression.  \nPattern compile(String regex)  \nCompiles the given regular expression into a pattern.  \nPattern compile(String regex, int flags)  \nCompiles the given regular expression into a pattern with the given flags.  \nboolean matches(String regex)  \nTells whether or not this string matches the given regular expression.  \nString[] split(CharSequence input)  \nSplits the given input sequence around matches of this pattern.  \nString quote(String s)  \nReturns a literal pattern String for the specified String.  \nPredicate\u003CString> asPredicate()  \nCreates a predicate which can be used to match a string.  \nMATCHER  \nAn engine that performs match operations on a character sequence by interpreting a pattern.  \nboolean matches()  \nAttempts to match the entire region against the pattern.  \nboolean find()  \nAttempts to find the next subsequence of the input sequence that matches the pattern.  \nint start()  \nReturns the start index of the previous match.  \nint end()  \nReturns the offset after the last character matched.  \nQUANTIFIERS  \n\n| Greedy | Reluctant | Possessive | Description |\n| --- | --- | --- | --- |\n| X? | X?? | X?+ | X, once or not at\u003Cbr>all. |\n| X* | X*? | X*+ | X, zero or more\u003Cbr>times. |\n| X+ | X+? | X++ | X, one or more\u003Cbr>times. |\n| X{n} | X{n}? | X{n}+ | X, exactly n times. |\n| X{n,} | X{n,}? | X{n,}+ | X, at least n times. |\n| X{n,m} | X{n,m}? | X{n,m}+ | X, at least n but\u003Cbr>not more than m\u003Cbr>times. |\n\nGreedy Matches the longest matching group.  \nReluctant Matches the shortest group.  \nPossessive Longest match or bust (no backoff) .  \nGROUPS & BACKREFERENCES  \nA group is a captured subsequence of characters which maybe used later in the expression with a backreference.  \n( . . .) Defines a group.  \n\\N Refers to a matched group.  \n(\\d\\d) A group of two digits.  \n(\\d\\d)/\\1 Two digits repeated twice.  \n\\1 Refers to the matched group.  \nLOGICAL OPERATIONS  \nXY X then Y.  \nX|Y X or Y.  \nLEARN HOW JREBEL AND XREBEL TRANSFORM ENTERPRISE SOFTWARE DEVELOPMENT.  \nTry for [free at](free at jrebel.com)[ j](free at jrebel.com)[rebel.com](free at jrebel.com)  \n[www.jrebel.com](www.jrebel.com)","cbCaiesNRyTEoO0h","https://ap.wps.com/l/cbCaiesNRyTEoO0h","pdf",183945,"English","# CHARACTER CLASSES\n## PREDEFINED CHARACTER CLASSES\n# BOUNDARY MATCHES\n# PATTERN FLAGS\n# USEFUL JAVA CLASSES & METHODS\n# MATCHER\n# QUANTIFIERS\n# GROUPS & BACKREFERENCES\n# LOGICAL OPERATIONS","[{\"question\":\"How do I define a character class that matches anything except specific characters in Java regex?\",\"answer\":\"Use negation with square brackets, for example [^abc] to match everything except a, b, or c.\"},{\"question\":\"What do the anchors ^ and $ mean in a regex pattern?\",\"answer\":\"^ matches the beginning of a line, and $ matches the end of a line, helping restrict where a match can occur.\"},{\"question\":\"How are quantifiers like ?, *, +, and {n,m} used to control match length?\",\"answer\":\"Use X? for zero or one, X* for zero or more, X+ for one or more, and X{n,m} for at least n and at most m occurrences; greedy, reluctant, and possessive variants change how the engine chooses matches.\"}]","Regex Cheat Sheet | PDF",1791914105]