Save & Share

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
Processing...

Test String

Code Generator

Generated Code

import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) { final String regex = "/\\*/?(\\n|[^/]|[^*]/)*\\*/"; final String string = "/*********************\n" + " * test\n" + " * multiline\n" + " */\n\n" + "/* next表示を半透明でなくする (カクつき防止のテスト) */\n" + "#content-tips-wrap {\n" + " opacity: 1!important;\n" + "}\n\n\n" + "/* path /_ct/* */\n\n" + "/* なるほどねー */\n\n" + "/***** compact footer ****/\n" + "@import url('/static/dinoportal/custom/content-compactfooter.css');\n\n" + "/***** Read All *****/\n" + "@import url('/static/dinoportal/custom/content-addmore.css');\n" + "@requirejs: url('/static/dinoportal/custom/content-addmore.js');\n\n" + "/* endpath */\n\n" + "/* ヘッダメニューを常にモバイルと同じにする */\n" + "@import url('/static/dinoportal/custom/header-menu-always-mobile.css');\n\n" + "/* メニューフィードの写真・カードの先頭を大きく */\n" + "@import url('/static/dinoportal/custom/menufeed-big-leading.css');\n\n" + "/* 写真・カードのフィードをモバイルで2列表示 */\n" + "@import url('/static/dinoportal/custom/feed-card-mobile-2cols.css');\n\n" + "/* サイドバーを左に */\n" + "@import url('/static/dinoportal/custom/sidebar-left.css');\n\n" + "/* サイドバーの要素をブロック分け */\n" + "@import url('/static/dinoportal/custom/sidebar-separate.css');\n\n" + "/* コンテンツカバー画像をぼかす */\n" + "/* @import url('/static/dinoportal/custom/content-cover-blur.css'); */\n\n" + "/* 各種色設定 (LESS記法) */\n" + "@import url('/static/dinoportal/custom/colors.less');\n" + "/* ベース */\n" + "@colors-base: hsl(207, 40%, 15%); /* 文字 */\n" + "@colors-base-bg: white; /* 背景 */\n" + "/* 箱囲み要素 */\n" + "@colors-base-box: @colors-base; /* 文字 */\n" + "@colors-base-box-bg: fade(@colors-base, 12%); /* 背景 */\n" + "/* ヘッダ */\n" + "@colors-header: #eee; /* 文字 */\n" + "@colors-header-bg: black; /* 背景 */\n" + "@colors-header-shadow: black; /* ヘッダ下線 */\n" + "/* ヘッダメニュー */\n" + "@colors-header-menu: @colors-header; /* 文字 */\n" + "@colors-header-menu-bg: @colors-header-bg; /* 背景 */\n" + "/* ヘッダメニュー(選択中メニュー) */\n" + "@colors-header-menu-active: white; /* 文字 */\n" + "@colors-header-menu-active-bg: transparent; /* 背景 */\n" + "@colors-header-menu-active-mark: hsl(0,100%,35%); /* 下線 */\n" + "/* ウィジェット */\n" + "@colors-widget: @colors-base-box; /* 文字 */\n" + "@colors-widget-bg: @colors-base-box-bg; /* 背景 */\n" + "/* タイトル系 */\n" + "@colors-menufeed-title: black; /* メニューフィードのブロックタイトル */\n" + "@colors-contents-title: @colors-base; /* フィードのコンテンツタイトル */\n" + "/* 写真・カード型フィード */\n" + "@colors-cards-bg: #eee; /* 写真・カード型フィードの背景 */\n" + "/* コンテンツ */\n" + "@colors-content-heading: @colors-base; /* 見出し */\n" + "@colors-content-heading-decoration: @colors-base; /* 見出し装飾色 */\n" + "@colors-content-subheading: @colors-base; /* 小見出し */\n" + "@colors-content-subheading-decoration: @colors-base; /* 小見出し装飾色 */\n" + "@colors-content-body-link: @colors-base; /* コンテンツ内リンク */\n" + "@colors-content-body-link-active: @colors-base; /* コンテンツ内リンク(アクティブ/ホバー) */\n" + "@colors-content-quote: @colors-base-box; /* 引用ボックス(文字) */\n" + "@colors-content-quote-bg: @colors-base-box-bg; /* 引用ボックス(背景) */\n" + "@colors-content-box: @colors-base-box; /* 箱囲み段落(文字) */\n" + "@colors-content-box-bg: @colors-base-box-bg; /* 箱囲み段落(背景) */\n\n\n" + "/* モバイルでメニューフィードサイドバーの.widget要素を最下部にまとめる */\n" + "/* @adjustwidgets: ~`window._adjustwidgets = {start:10000, step:0}`; */\n\n\n" + "/* モバイル、メニューフィード、通常リスト型表示の後続要素のタイトルをボールドに */\n" + "@media (max-width:767px) {\n" + " #newsfeed .newsfeed-block.newsfeed-all-display-type-list .wfcontent.not-has-display-type .content-title {\n" + " font-weight:bold;\n" + " font-size:110%;\n" + " }\n" + "}\n\n" + "/* 記事小見出し */\n" + ".article > h3 {\n" + " border:1px solid hsl(171, 80%, 45%);\n" + " padding:.4em .5em .3em 1.5em;\n" + " position:relative;\n" + "}\n" + ".article > h3:before {\n" + " content:'';\n" + " position:absolute;\n" + " top:.4em;\n" + " left:.4em;\n" + " bottom:.4em;\n" + " width:.75em;\n" + " background:hsl(171, 80%, 45%);\n" + "}\n\n" + ".article > h4 {\n" + " font-size:100%;\n" + " border-left:.2em solid hsl(171, 80%, 45%);\n" + " padding-left:.4em;\n" + "}\n\n" + "/****** banners-2col debug *******/\n" + ".banners-2col { position:relative; }\n" + ".banners-2col > a > img {\n" + " display:block;\n" + " width:100%;\n" + " margin:0;\n" + " padding:0;\n" + "}\n" + ".banners-2col > a {\n" + " margin:0; padding:0;\n" + " display:inline-block;\n" + " position:relative;\n" + " width:49%;\n" + " width:-webkit-calc( 50% - 2px );\n" + " width:calc( 50% - 2px );\n" + " width:~\"calc( 50% - 2px )\"; /* for LESS */\n" + " display:inline-block;\n" + " vertical-align:top;\n" + "}\n" + ".banners-2col > a:hover {\n" + " text-decoration:none;\n" + "}\n" + ".banners-2col > a:nth-child(2n+1) {\n" + " margin-right:2%;\n" + " margin-right:4px;\n" + "}\n" + ".banners-2col > a:nth-child(n+3) {\n" + " margin-top:4px;\n" + "}"; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(string); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html