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

$re = '/require\(\'(.+?)\'\)/'; $str = '\'use strict\'; var path = require(\'path\'); var _ = require(\'lodash\'); var gulp = require(\'gulp\'); require(\'gulp-help\')(gulp); var corejs = require(\'gulp-corejs\'); //region Build gulp.task(\'_bower_clean\', function () { var bower = require(\'bower\'); return bower.commands.cache.clean([\'corejs\', \'pnotify\', \'ui-bootstrap\', \'emply-font\', \'modernizr\']); }); gulp.task(\'bower\', [\'_bower_clean\'], function () { var bower = require(\'gulp-bower\'); return bower({ cmd: \'update\' }) .pipe(gulp.dest(\'bower_components\')); }); gulp.task(\'compile\', function (cb) { var buildConfig = { appDir: \'src\', baseUrl: \'.\', paths: { text: \'../bower_components/requirejs-text/text\', html: \'../bower_components/requirejs-html/html\', jquery: \'empty:\', angular: \'empty:\', \'angular-cache\': \'empty:\', ngSanitize: \'empty:\', pnotify: \'empty:\', \'pnotify.modal\': \'empty:\', \'pnotify.confirm\': \'empty:\', \'pnotify.callbacks\': \'empty:\', \'pnotify.nonblock\': \'empty:\', \'ui.bootstrap\': \'empty:\', infiniteScroll: \'empty:\', \'jquery.tabbable\': \'empty:\', cfpHotkeys: \'empty:\', textile: \'empty:\', Modernizr: \'empty:\', \'tmh.dynamicLocale\': \'empty:\' }, config: { html: { comments: \'strip\', whitespaceBetweenTags: \'collapse\', whitespaceBetweenTagsAndText: \'collapse\', whitespaceWithinTags: \'collapse\' } }, dir: \'compiled\', removeCombined: true, optimize: \'none\', skipDirOptimize: true, fileExclusionRegExp: /\\.spec\\.js/, modules: [ { name: \'cmHelpers/module\', exclude: [\'text\', \'html\'] }, { name: \'cmMessages/module\', exclude: [\'text\', \'html\'] }, { name: \'cmYaMetrika/module\' }, { name: \'cmFormPrimitives/module\', exclude: [\'text\', \'html\', \'cmHelpers/module\'] }, { name: \'cmGoogleAnalytics/module\', exclude: [\'text\', \'html\', \'cmMessages/module\'] }, { name: \'cmWikiHelp/module\', exclude: [\'html\', \'cmHelpers/module\', \'cmMessages/module\', \'cmTranslate/module\'] }, { name: \'cmMultiselect/module\', exclude: [\'text\', \'html\', \'cmFormPrimitives/module\', \'cmHelpers/module\'] }, { name: \'cmSelectControls/module\', exclude: [ \'text\', \'html\', \'cmHelpers/module\', \'cmFormPrimitives/module\', \'cmWikiHelp/module\', \'cmMessages/module\', \'cmTranslate/module\' ] }, { name: \'cmTranslate/module\', exclude: [\'text\', \'html\', \'cmHelpers/module\'] } ] }; corejs.build.compile(buildConfig, cb); gulp.src(\'bower.json\') .pipe(gulp.dest(\'./compiled\')); }); gulp.task(\'clean\', function (cb) { require(\'del\')([\'compiled/**/*.html\', \'dist\'], function () { require(\'remove-empty-directories\')(\'compiled\'); cb(); }); }); gulp.task(\'zip\', function () { var zip = require(\'gulp-zip\'); var bowerCfg = require(path.resolve(\'./bower.json\')); var files = [ \'compiled/**/*\', \'!./**/*.txt\' ]; gulp.src(files) .pipe(zip(\'corejs-\' + bowerCfg.version + \'.zip\')) .pipe(gulp.dest(\'./dist\')); gulp.src(files) .pipe(zip(\'corejs-latest.zip\')) .pipe(gulp.dest(\'./dist\')); }); function build (cb, excluded) { var tasks = [ \'bower\', \'compile\', \'clean\', \'zip\' ]; tasks = tasks.concat([cb]); _.remove(tasks, function (task) { return _.includes(excluded, task); }); require(\'run-sequence\').apply(undefined, tasks); } gulp.task(\'build\', \'Build production version (./dist folder)\', function (cb) { build(cb); }); gulp.task(\'fastBuild\', \'Build production version (./dist folder)\', function (cb) { build(cb, [\'bower\', \'compress\']); }); //endregion //region Developer tools gulp.task(\'bump\', \'Increment version\', function () { return corejs.bump([\'package.json\', \'bower.json\']) .pipe(gulp.dest(\'./\')); }); gulp.task(\'styles\', \'Compile CSS\', function () { return corejs.styles([\'demo/styles/index.less\']) .pipe(gulp.dest(\'demo/styles\')); }); gulp.task(\'browsersync\', function () { require(\'browser-sync\').create().init({ files: [ \'{src,demo}/**/*\', \'*.{json,js}\' ], watchOptions: { ignoreInitial: true, ignored: \'{src,demo}/**/*.less\' }, open: false, proxy: \'localhost:2000\', port: 2015, logPrefix: \'BrowserSync\', logConnections: true }); }); gulp.task(\'assemble\', [\'styles\', \'i18n\', \'packSvg\']); gulp.task(\'watch\', [\'assemble\'], function () { // styles corejs.watch([\'src/**/*.less\', \'demo/**/*.less\'], [\'styles\']); // translates corejs.watch([\'src/**/*.json\', \'demo/**/*.json\'], [\'i18n\']); // svg packs corejs.watch([\'src/**/*.svg\'], [\'packSvg\']); }); gulp.task(\'live\', [\'browsersync\', \'watch\']); gulp.task(\'i18n\', function () { var extend = require(\'gulp-extend\'); var locales = [\'ru\', \'en\']; _.forEach(locales, function (locale) { var jsonName = locale + \'.json\'; gulp.src([\'src/**/\' + jsonName, \'demo/**/\' + jsonName]) .pipe(extend(jsonName)) .pipe(gulp.dest(\'i18n\')); }); }); gulp.task(\'packSvg\', function () { return corejs.packSvg([\'src/**/*.svg\'], \'pack.svg\') .pipe(gulp.dest(\'demo/images/\')); }); //endregion //region Karma tests gulp.task(\'test\', \'Run tests once and exit\', function (done) { corejs.karma.test(done, \'karma.conf.js\'); }); gulp.task(\'tdd\', \'Run tests and start watching\', function (done) { corejs.karma.tdd(done, \'karma.conf.js\'); }); gulp.task(\'test:jenkins\', \'Run tests once and build reports\', function (done) { corejs.karma.jenkins(done, \'karma.conf.js\'); }); //endregion //region Code style and lint var JS_FILES = [\'src/**/*.js\']; gulp.task(\'lint\', \'Check JS syntax and show errors\', function () { return corejs.lint.check(JS_FILES, \'jshint-stylish\'); }); gulp.task(\'lint:storm\', \'Check JS syntax and show errors\', function () { return corejs.lint.check(JS_FILES, \'storm\'); }); gulp.task(\'lint:jenkins\', \'Check JS syntax and generate reports for jenkins\', function () { return corejs.lint.jenkins(JS_FILES, \'reports/corejs-lint.xml\'); }); gulp.task(\'jscs\', \'Check JS code style\', function () { return corejs.jscs.check(JS_FILES); }); gulp.task(\'jscs:storm\', \'Check JS code style\', function () { return corejs.jscs.check(JS_FILES, \'storm\'); }); gulp.task(\'jscs:jenkins\', \'Check JS code style and generate report for jenkins\', function () { return corejs.jscs.jenkins(JS_FILES, \'reports/corejs-codestyle.xml\'); }); gulp.task(\'storm\', \'Run JS check style and syntax and show short report\', [\'lint:storm\', \'jscs:storm\']); //endregion gulp.task(\'jenkins\', \'Run all jenkins-specific tasks\', [\'lint:jenkins\', \'test:jenkins\', \'jscs:jenkins\']); '; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);

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 PHP, please visit: http://php.net/manual/en/ref.pcre.php