Regular Expressions 101

Save & Share

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8
  • .NET 7.0 (C#)
  • Rust
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests

Tools

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

/
/
m

Test String

Code Generator

Generated Code

$re = '/^ *analyticsConfig\.analyticsClass = WLAnalyticsWrapper\.self/m'; $str = '@objc (WLAppDelegate) open class WLAppDelegate: LUUIBaseAppDelegate { fileprivate var overrideTabBarControllerDelegate: LUUITabBarControllerDelegate? open override var tabBarControllerDelegate: UITabBarControllerDelegate? { if overrideTabBarControllerDelegate == nil { overrideTabBarControllerDelegate = WLTabBarControllerDelegate() } return overrideTabBarControllerDelegate } @objc open override func applyAppearance() { super.applyAppearance() WLAppearance.apply() } // swiftlint:disable:next function_body_length @objc open override func configureApplicationKeys() { let appConfig: LUUIApplicationConfiguration = LUUIApplicationConfiguration.shared() appConfig.crashlyticsAPIKey = WLCrashlyticsAPIKey appConfig.googleAnalyticsTrackingID = WLGoogleAnalyticsTrackingID appConfig.inviteFriendsShowsQRCode = true appConfig.referAFriendCampaignID = NSNumber(value: WLReferAFriendCampaignID) appConfig.usesSideNavigation = false appConfig.enablePaymentPreferenceSelection = true appConfig.sendGiftCardFromSettings = true appConfig.claimBankingEnabled = true appConfig.showEnableLocationAlert = true appConfig.enableFacebookLogin = true appConfig.myRewardsEnabled = true appConfig.showOptionalInfoDuringRegistration = true appConfig.analyticsConfiguration = analyticsConfiguration() appConfig.cardReaderConfiguration = cardReaderConfiguration() appConfig.appLocationsScreen = .mapLocations appConfig.allowsOrderAhead = true appConfig.enableOrderAheadLandingScreen = true appConfig.allowsOrderAheadDelivery = false appConfig.orderAheadMenuLayoutStyle = .list appConfig.modularRewardsEnabled = true appConfig.enableOrderAheadTipCell = false appConfig.levelupAPIKey = WLLevelUpAPIKey appConfig.environmentConfigProd.levelupAppID = WLLevelUpAPIKey as NSString appConfig.environmentConfigStaging.levelupAPIKey = WLLevelUpAPIKeyStaging as NSString appConfig.levelupAppID = WLLevelUpAppID appConfig.environmentConfigProd.levelupAppID = WLLevelUpAppID as NSString appConfig.environmentConfigStaging.levelupAppID = WLLevelUpAppIDStaging as NSString if WLLegacyLoyaltyCampaignID > 0 { appConfig.loyaltyMigrationCampaignID = NSNumber(value: WLLegacyLoyaltyCampaignID) appConfig.environmentConfigProd.loyaltyMigrationCampaignID = appConfig.loyaltyMigrationCampaignID! appConfig.environmentConfigStaging.loyaltyMigrationCampaignID = NSNumber(value: WLLegacyLoyaltyCampaignIDStaging) } if WLReferAFriendCampaignID > 0 { appConfig.referAFriendCampaignID = NSNumber(value: WLReferAFriendCampaignID) appConfig.environmentConfigProd.referAFriendCampaignID = appConfig.referAFriendCampaignID! appConfig.environmentConfigStaging.referAFriendCampaignID = NSNumber(value: WLReferAFriendCampaignIDStaging) } if let rewardsLoyaltyCampaignID: NSNumber = applicationConfig().rewardsLoyaltyCampaignID { appConfig.rewardsLoyaltyCampaignID = rewardsLoyaltyCampaignID appConfig.rewardsLoyaltyCampaignType = .spendBased } else if WLRewardsLoyaltyCampaignID > 0 { appConfig.rewardsLoyaltyCampaignID = NSNumber(value: WLRewardsLoyaltyCampaignID) appConfig.environmentConfigProd.rewardsLoyaltyCampaignID = appConfig.rewardsLoyaltyCampaignID! appConfig.environmentConfigStaging.rewardsLoyaltyCampaignID = NSNumber(value: WLRewardsLoyaltyCampaignIDStaging) appConfig.rewardsLoyaltyCampaignType = .spendBased } if WLRewardsStatusCampaignID > 0 { appConfig.rewardsStatusCampaignID = NSNumber(value: WLRewardsStatusCampaignID) appConfig.environmentConfigProd.rewardsStatusCampaignID = appConfig.rewardsStatusCampaignID! appConfig.environmentConfigStaging.rewardsStatusCampaignID = NSNumber(value: WLRewardsStatusCampaignIDStaging) appConfig.rewardsStatusCampaignType = .spendBased } appConfig.analyticsConfiguration = analyticsConfiguration() appConfig.cardReaderConfiguration = cardReaderConfiguration() appConfig.crashReportingConfiguration = crashReportingConfiguration() appConfig.viewControllerConfiguration = viewControllerConfiguration() appConfig.viewConfiguration = viewConfiguration() appConfig.cellConfiguration = cellConfiguration() } @objc open func analyticsConfiguration() -> LUUIAnalyticsConfiguration { let analyticsConfig: LUUIAnalyticsConfiguration = LUUIAnalyticsConfiguration() analyticsConfig.analyticsClass = WLAnalyticsWrapper.self return analyticsConfig } @objc open func cardReaderConfiguration() -> LUUICardReaderConfiguration { let cardReaderConfig: LUUICardReaderConfiguration = LUUICardReaderConfiguration() cardReaderConfig.cardReaderViewControllerClass = WLCardReaderViewController.self return cardReaderConfig } @objc open func crashReportingConfiguration() -> LUUICrashReportingConfiguration { let crashReportingConfig: LUUICrashReportingConfiguration = LUUICrashReportingConfiguration() crashReportingConfig.crashReportingWrapperClass = WLCrashlyticsWrapper.self return crashReportingConfig } @objc open override func tabBarViewControllers() -> [Any]? { return UITabBarController.loggedInTabBarController() } @objc open func viewConfiguration() -> LUUIViewConfiguration { let config = LUUIViewConfiguration() config.imageRewardProgressionViewClass = WLImageRewardProgressionView.self return config } @objc open func viewControllerConfiguration() -> LUUIViewControllerConfiguration { let config = LUUIViewControllerConfiguration() config.confirmGiftCardOrderViewControllerClass = WLConfirmGiftCardOrderViewController.self config.forgotPasswordViewControllerClass = WLForgotPasswordViewController.self config.getStartedViewControllerClass = WLGetStartedViewController.self config.interstitialViewControllerClass = WLInterstitialViewController.self config.inviteFriendsViewControllerClass = WLInviteFriendsViewController.self config.logInViewControllerClass = WLLogInViewController.self config.mapLocationsLocationDetailViewControllerClass = WLMapLocationsLocationDetailViewController.self config.mapLocationsSearchViewControllerClass = WLMapLocationsSearchViewController.self config.mapLocationsViewControllerClass = WLMapLocationsViewController.self config.orderAheadLandingViewControllerClass = WLOrderAheadLandingViewController.self config.orderGiftCardViewControllerClass = WLOrderGiftCardViewController.self config.paymentMethodDetailViewControllerClass = WLPaymentMethodDetailViewController.self config.payViewControllerClass = WLPayViewController.self config.scanSuccessViewControllerClass = WLScanSuccessViewController.self config.selectPaymentPreferenceViewControllerClass = WLSelectPaymentPreferenceViewController.self config.settingsViewControllerClass = WLSettingsViewController.self config.signUpViewControllerClass = WLSignUpViewController.self config.signUpOrLogInViewControllerClass = WLSignUpOrLogInViewController.self config.transactionDetailViewControllerClass = WLTransactionDetailViewController.self config.transactionHistoryViewControllerClass = WLTransactionHistoryViewController.self config.rewardsStatusLevelsViewControllerClass = WLRewardsStatusLevelsViewController.self config.permissionPrimerViewControllerClass = WLPermissionPrimerViewController.self config.selectPaymentMethodViewControllerClass = WLSelectPaymentMethodViewController.self config.availableRewardsDrawerViewControllerClass = WLAvailableRewardsDrawerViewController.self config.modularRewardsViewControllerClass = WLModularRewardsViewController.self return config } @objc open func cellConfiguration() -> LUUICellConfiguration { let config = LUUICellConfiguration() config.captionedImageHeaderViewCellClass = WLCaptionedImageHeaderViewCell.self config.locationCellClass = WLLocationCell.self config.mapLocationsButtonsCellClass = WLMapLocationsButtonsCell.self config.mapLocationsLocationCellClass = WLMapLocationsLocationCell.self config.transactionEarnedCreditCellClass = WLTransactionEarnedCreditCell.self config.transactionHistoryCellClass = WLTransactionHistoryCell.self config.statusLevelGoalCellClass = WLStatusLevelGoalCell.self config.availableRewardIconTableViewCellClass = WLAvailableRewardIconTableViewCell.self config.orderAheadSpecialInstructionsCellClass = WLOrderAheadSpecialInstructionsCell.self config.orderAheadCategoryMenuListTableViewCellClass = WLOrderAheadCategoryMenuListTableViewCell.self return config } @objc open override func settingsSectionsData() -> LUUIStaticTableViewData { let data = LUUIStaticTableViewSectionsData() data.add(WLStaticTableViewSectionFactory.customSocialSection()) data.add(WLStaticTableViewSectionFactory.customAccountSection()) data.add(WLStaticTableViewSectionFactory.customHelpSection()) return data } } '; preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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