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 = "(%([^:]+):([^%]+)%)"; final String string = "<!DOCTYPE html>/\n\n" + "<html>\n" + "<head>\n" + "<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\" />\n" + "<title>Testing the checkAndChangeToUrl-Function (Version 5)</title>\n\n" + "<link rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"[__protocol__]://[__server__]:[__port__]/weblis-ext3/ext/resources/css/ext-all.css\\\" />\n" + "<script type=\\\"text/javascript\\\" src=\\\"[__protocol__]://[__server__]:[__port__]/weblis-ext3/ext/adapter/ext/ext-base-debug.js\\\"></script>\n" + "<script type=\\\"text/javascript\\\" src=\\\"[__protocol__]://[__server__]:[__port__]/weblis-ext3/ext/ext-all-debug.js\\\"></script>\n" + "<script type=\\\"text/javascript\\\" src=\\\"[__protocol__]://[__server__]:[__port__]/weblis-ext3/ext/locale/ext-lang-de.js\\\"></script>\n\n" + "<script type=\\\"text/javascript\\\" src=\\\"[__protocol__]://[__server__]:[__port__]/weblis-resources/js/jquery/jquery-3.2.1.js\\\"></script>\n\n" + "<script type=\\\"text/javascript\\\">\n\n" + "function checkAndChangeToUrl(url, maxRetries, waitTime, waitFunc, startFunc, successFunc, errorFunc) {\n" + "console.log(\\\"ENTER checkAndChangeToUrl('\\\"+url+\\\"', \\\"+maxRetries+\\\", \\\"+waitTime+\\\")\\\");\n" + "var nRetry = 0;\n" + "var checkUrl = function () {\n" + "$.ajax({\n" + "url: url,\n" + "context: document.body,\n" + "crossDomain: true,\n" + "error: function(jqXHR, textStatus, errorThrown) {\n" + "console.error(textStatus + \\\";\n" + "\\\" + errorThrown);\n" + "nRetry++;\n" + "if (nRetry <= maxRetries) {\n" + "waitFunc.call(jqXHR, jqXHR);\n" + "console.log(\\\"Retry #\\\" + nRetry);\n" + "var timeout = (nRetry == 0 ? 0 : waitTime);\n" + "console.log(\\\"timeout = \\\" + timeout);\n" + "setTimeout(checkUrl, timeout);\n" + "if (nRetry === 1) {\n" + "console.log(\\\"**** Try and open the target application ****\\\");\n" + "// PROBLEM: parent[.parent].handleExternalEvent() existiert nicht...\n" + "startFunc.call(jqXHR, jqXHR);\n" + "}\n" + "} else {\n" + "errorFunc.call(jqXHR, jqXHR);\n" + "}\n" + "return;\n" + "},\n" + "success : function(data, textStatus, jqXHR) {\n" + "console.log(\\\"Success!\\\");\n" + "successFunc.call(jqXHR, jqXHR);\n" + "}\n" + "}).done(function() {\n" + "$( this ).addClass( \\\"done\\\" );\n" + "console.log(\\\"Done!\\\");\n" + "});\n" + "};\n" + "// Wir setzen das Ganze in Gang...\n" + "checkUrl();\n" + "}\n\n" + "function test_1(checkUrl, targetUrl, launchUrl) {\n" + "//var url = \\\"%param:checkUrl%\\\"; \n" + "//var url = \\\"http://localhost:8080/RechercheServlet/rest/forcont/fxLIS?DOKID=1&VID=1&OP=RECEIVE\\\"; \n" + "//var url = \\\"http://localhost:8085/gn\\\";\n" + "console.log(\\\"VOR checkAndChangeToUrl('\\\"+checkUrl+\\\"', 2, 5000) ...\\\");\n" + "var ret = checkAndChangeToUrl(checkUrl, 2, 2000, function(jqXHR) {\n" + "console.log(\\\"Waiting...\\\");\n" + "}, function(jqXHR) {\n" + "console.log(\\\"Start application...\\\");\n" + "$.ajax({\n" + "url: %param:launchUrl%, //\\\"/opusp-rest/client-action/execute/local/GIS_Launch\\\",\n" + "context: document.body,\n" + "crossDomain: false, //true, -- SYNCHRONER AUFRUF - SCHWERE SÜNDE...\n" + "headers: {\n" + "'Accept' : 'application/x-java-jnlp-file', /* application/jnlp */\n" + "'Content-Description' : 'File Transfer',\n" + "'Content-Disposition' : 'attachment; filename=GIS_Launch.jnlp'\n" + "},\n" + "error: function(jqXHR, textStatus, errorThrown) {\n" + "console.error(\\\"Fehler bei Aktion GIS_Launch:\n" + "\\\" + textStatus + \\\";\n" + "\\\" + errorThrown);\n" + "return;\n" + "},\n" + "success : function(data, textStatus, jqXHR) {\n" + "console.log(\\\"GIS_Launch: Success! JNLP = '\\\" + data + \\\"'\\\");\n" + "}\n" + "}).done(function() {\n" + "$( this ).addClass( \\\"done\\\" );\n" + "console.log(\\\"GIS_Launch: Done!\\\");\n" + "});\n" + "}, function(jqXHR) {\n" + "console.log(\\\"Success.\\\");\n" + "window.location.href = targetUrl;\n" + "}, function(jqXHR) {\n" + "console.log(\\\"Error: \\\" + jqXHR.statusText + \\\", jqXHR.state() = \\\" + jqXHR.state());\n" + "});\n" + "console.log(\\\"LEAVE test_1.\\\");\n" + "}\n\n" + "function performTest_1() {\n" + "test_1(\n" + "\\\"[__checkUrl__]\\\", // Parameter: checkUrl, z.B. \\\"http://localhost:8080/RechercheServlet\\\" \n" + "\\\"%param:targetUrl%\\\", // Parameter: targetUrl, z.B. \\\"http://localhost:8080/RechercheServlet/rest/forcont/fxLIS?DOKID=1&VID=1&OP=RECEIVE\\\"\n" + "\\\"[__launchUrl__]\\\" // Parameter: launchUrl, z.B. \\\"/opusp-rest/client-action/execute/local/GIS_Launch\\\"\n" + ")\n" + "}\n\n" + "$.when($.ready).then(function() {\n" + "performTest_1();\n" + "});\n\n" + "</script>\n" + "</head>\n" + "<body>\n" + "<a id=\\\"test_1\\\" onclick=\\\"performTest_1();\\\"><button type=\\\"button\\\">Perform Test #1</button></a>\n" + "</body>\n" + "</html>\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