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

/
/
g

Test String

Substitution

Processing...

Code Generator

Generated Code

#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox Local $sRegex = "function\(([^)]*)\) {\s+(?:return )?([^;\v]+);\s+}" Local $sString = "goog.provide('smb.controllers.SearchboxForDashboards');" & @CRLF & _ "" & @CRLF & _ "goog.require('goog.array');" & @CRLF & _ "goog.require('goog.functions');" & @CRLF & _ "goog.require('goog.iter');" & @CRLF & _ "goog.require('goog.object');" & @CRLF & _ "goog.require('goog.string.format');" & @CRLF & _ "goog.require('smb.model.Dashboard');" & @CRLF & _ "goog.require('smb.model.User');" & @CRLF & _ "" & @CRLF & _ "goog.scope(function() {" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "var User = smb.model.User;" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @param {!angular.Scope} $scope Injected Angular scope." & @CRLF & _ " * @param {!angular.Route} $route Injected angular route." & @CRLF & _ " * @param {!angular.Location} $location Injected angular location." & @CRLF & _ " * @param {!angular.Resource} $resource Injected angular resource." & @CRLF & _ " * @param {!smb.services.navigation} navigationService The navigationService." & @CRLF & _ " * @constructor" & @CRLF & _ " */" & @CRLF & _ "smb.controllers.SearchboxForDashboards = function($scope, $route, $location," & @CRLF & _ " $resource, navigationService) {" & @CRLF & _ " /** @private {!angular.Scope} */" & @CRLF & _ " this.scope_ = $scope;" & @CRLF & _ "" & @CRLF & _ " /** @private {!smb.services.navigation} */" & @CRLF & _ " this.navigationService_ = navigationService;" & @CRLF & _ "" & @CRLF & _ " /** @private {!angular.Route} */" & @CRLF & _ " this.route_ = $route;" & @CRLF & _ "" & @CRLF & _ " /** @private {!angular.Location} */" & @CRLF & _ " this.location_ = $location;" & @CRLF & _ "" & @CRLF & _ " /** @private {!angular.Resource} */" & @CRLF & _ " this.resource_ = $resource;" & @CRLF & _ "" & @CRLF & _ " /** @private */" & @CRLF & _ " this.active_ = this.scope_.active;" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * Current search string." & @CRLF & _ " * @export {string}" & @CRLF & _ " */" & @CRLF & _ " this.search = '';" & @CRLF & _ "" & @CRLF & _ " /**" & @CRLF & _ " * The list of current search results." & @CRLF & _ " * @export {!Array<!SearchboxForDashboards.SearchResultStruct>}" & @CRLF & _ " */" & @CRLF & _ " this.searchResults = [];" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "var SearchboxForDashboards = smb.controllers.SearchboxForDashboards;" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @return {boolean} Whether there are no search results." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.hasNoSearchResults_ = function() {" & @CRLF & _ " return this.searchResults.length == 0;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Types of component contained in a search result." & @CRLF & _ " * @enum {string}" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.ComponentType = {" & @CRLF & _ " TAG: 'tag'," & @CRLF & _ " TITLE: 'title'," & @CRLF & _ " DESCRIPTION: 'description'" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * FIRST_SUBSEARCH is a multiplier applied for matches starting at the beginning" & @CRLF & _ " * of the text as a whole. STARTING_MATCH is applies for matches at the" & @CRLF & _ " * beginning of any word." & @CRLF & _ " * @typedef {{" & @CRLF & _ " * FIRST_SUBSEARCH: number," & @CRLF & _ " * STARTING_MATCH: number" & @CRLF & _ " * }}" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.ComponentWeight;" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Weight settings for the various components, can be tweaked to change results." & @CRLF & _ " * @const {!Object<!SearchboxForDashboards.ComponentType," & @CRLF & _ " * !SearchboxForDashboards.ComponentWeight>}" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.WEIGHTS = goog.object.create(" & @CRLF & _ " SearchboxForDashboards.ComponentType.TAG, {" & @CRLF & _ " FIRST_SUBSEARCH: 1," & @CRLF & _ " STARTING_MATCH: 2" & @CRLF & _ " }," & @CRLF & _ " SearchboxForDashboards.ComponentType.TITLE, {" & @CRLF & _ " FIRST_SUBSEARCH: 10," & @CRLF & _ " STARTING_MATCH: 10" & @CRLF & _ " }," & @CRLF & _ " SearchboxForDashboards.ComponentType.DESCRIPTION, {" & @CRLF & _ " FIRST_SUBSEARCH: 10," & @CRLF & _ " STARTING_MATCH: 10" & @CRLF & _ " }" & @CRLF & _ ");" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * One feature of the search result." & @CRLF & _ " * @typedef {{" & @CRLF & _ " * type: !SearchboxForDashboards.ComponentType," & @CRLF & _ " * match: string," & @CRLF & _ " * tag: (string|undefined)," & @CRLF & _ " * title: (string|undefined)," & @CRLF & _ " * score: number," & @CRLF & _ " * }}" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.SearchResultComponent;" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Search result with scoring information." & @CRLF & _ " * @typedef {{" & @CRLF & _ " * dashboard: !smb.model.Dashboard," & @CRLF & _ " * components: !Array<!SearchResultComponent>," & @CRLF & _ " * bestTitleMatch: ?string," & @CRLF & _ " * bestDescriptionMatch: ?string," & @CRLF & _ " * score: number," & @CRLF & _ " * }}" & @CRLF & _ "*/" & @CRLF & _ "SearchboxForDashboards.SearchResultStruct;" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Gives a match score for a dashboard." & @CRLF & _ " * TODO(b/27602041) Do more in-depth research into whether there are feasible" & @CRLF & _ " * alternatives to writing custom search logic that still give us fine" & @CRLF & _ " * control over ranking." & @CRLF & _ " * @param {string} search The text to search." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard to which to apply the" & @CRLF & _ " * search." & @CRLF & _ " * @param {boolean=} opt_recur Whether to recursively perform subsearches" & @CRLF & _ " * for the different words in the search, i.e "word1 word2 word3" would" & @CRLF & _ " * do "word1 word2" and "word2 word3", and then the same recursively." & @CRLF & _ " * @param {boolean=} opt_isFirstSearch Whether this is should be treated as" & @CRLF & _ " * matching at the beginning of a search." & @CRLF & _ " * @return {!SearchResultStruct} The result of the search." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doDashboardSearch_ =" & @CRLF & _ " function(search, dashboard, opt_recur, opt_isFirstSearch) {" & @CRLF & _ " var isFirstSearch = opt_isFirstSearch;" & @CRLF & _ " var struct = {dashboard: dashboard, components: []};" & @CRLF & _ "" & @CRLF & _ " var titleSearchComponent =" & @CRLF & _ " this.doTitleSearch_(search, dashboard, isFirstSearch);" & @CRLF & _ " if (titleSearchComponent != null) {" & @CRLF & _ " struct.components.push(titleSearchComponent);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " var descriptionSearchComponent =" & @CRLF & _ " this.doDescriptionSearch_(search, dashboard, isFirstSearch);" & @CRLF & _ " if (descriptionSearchComponent != null) {" & @CRLF & _ " struct.components.push(descriptionSearchComponent);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " var tagSearchComponent = this.doTagSearch_(search, dashboard);" & @CRLF & _ " if (tagSearchComponent != null) {" & @CRLF & _ " struct.components.push(tagSearchComponent);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " // now we search for all the n-gram substrings" & @CRLF & _ " if (opt_recur) {" & @CRLF & _ " var re = /\s+/;" & @CRLF & _ " var tokens = search.split(re);" & @CRLF & _ " var len = tokens.length;" & @CRLF & _ " for (var runLength = len - 1; runLength > 0; runLength--) {" & @CRLF & _ " for (var start = 0; start <= len - runLength; start++) {" & @CRLF & _ " var subArr = tokens.slice(start, start + runLength);" & @CRLF & _ " var newSearch = subArr.join(' ');" & @CRLF & _ " var isFirstSearch = start == 0;" & @CRLF & _ " var subStruct =" & @CRLF & _ " this.doDashboardSearch_(newSearch, dashboard, false, isFirstSearch);" & @CRLF & _ " struct.components = struct.components.concat(subStruct.components);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " struct.components = struct.components.sort(function(a, b) {" & @CRLF & _ " return b.score - a.score;" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " var bestTitleMatch = goog.array.find(struct.components, function(component) {" & @CRLF & _ " return component.type == SearchboxForDashboards.TITLE;" & @CRLF & _ " });" & @CRLF & _ " if (bestTitleMatch) {" & @CRLF & _ " struct.bestTitleMatch = bestTitleMatch.title;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " var bestDescriptionMatch = goog.array.find(struct.components," & @CRLF & _ " function(component) {" & @CRLF & _ " return component.type == SearchboxForDashboards.DESCRIPTION;" & @CRLF & _ " });" & @CRLF & _ " if (bestDescriptionMatch) {" & @CRLF & _ " struct.bestDescriptionMatch = bestDescriptionMatch.description;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " this.computeAndSetSearchResultScore_(struct);" & @CRLF & _ " return struct;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Computes score for the search result and sets score for the search result." & @CRLF & _ " * @param {!SearchResultStruct} searchResult The search result to operate on." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.computeAndSetSearchResultScore_ =" & @CRLF & _ " function(searchResult) {" & @CRLF & _ " searchResult.score = searchResult.components.map(function(component) {" & @CRLF & _ " return component.score;" & @CRLF & _ " }).reduce(function(a, b) { return a + b; }, 0);" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Performs search on dashboard title." & @CRLF & _ " * @param {string} search The text to search." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard to perform search on." & @CRLF & _ " * @param {boolean} isFirstSearch Whether to treat this as matching at the" & @CRLF & _ " * beginning of a search." & @CRLF & _ " * @return {?SearchboxForDashboards.SearchResultComponent} The search match" & @CRLF & _ " * component." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doTitleSearch_ =" & @CRLF & _ " function(search, dashboard, isFirstSearch) {" & @CRLF & _ " var title = dashboard.titleDisplayText || dashboard.menuDisplayText;" & @CRLF & _ " return this.doTextSearch_(search, title, isFirstSearch," & @CRLF & _ " SearchboxForDashboards.ComponentType.TITLE);" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Performs search on dashboard description." & @CRLF & _ " * @param {string} search The text to search." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard to perform search on." & @CRLF & _ " * @param {boolean} isFirstSearch Whether to treat this as matching at the" & @CRLF & _ " * beginning of a search." & @CRLF & _ " * @return {?SearchboxForDashboards.SearchResultComponent} The search match" & @CRLF & _ " * component." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doDescriptionSearch_ =" & @CRLF & _ " function(search, dashboard, isFirstSearch) {" & @CRLF & _ " var title = dashboard.titleDisplayText || dashboard.menuDisplayText;" & @CRLF & _ " return this.doTextSearch_(search, title, isFirstSearch," & @CRLF & _ " SearchboxForDashboards.ComponentType.DESCRIPTION);" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Searches the text." & @CRLF & _ " * @param {string} search" & @CRLF & _ " * @param {string} text" & @CRLF & _ " * @param {boolean} isFirstSearch" & @CRLF & _ " * @param {smb.controllers.SearchboxForDashboards.ComponentType} type" & @CRLF & _ " * @return {?SearchboxForDashboards.SearchResultComponent} The search match" & @CRLF & _ " * component." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doTextSearch_ = function(search, text," & @CRLF & _ " isFirstSearch, type) {" & @CRLF & _ " var score = 0;" & @CRLF & _ " var searchRegex = new RegExp(search, 'i');" & @CRLF & _ " var match = text.match(searchRegex);" & @CRLF & _ " if (!match) {" & @CRLF & _ " return null;" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " score = match[0].length;" & @CRLF & _ " var weight = SearchboxForDashboards.WEIGHTS[type];" & @CRLF & _ " if (text.toLowerCase().startsWith(match[0].toLowerCase())) {" & @CRLF & _ " score *= weight.STARTING_MATCH;" & @CRLF & _ " if (isFirstSearch) {" & @CRLF & _ " score *= weight.FIRST_SUBSEARCH;" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return goog.object.create(" & @CRLF & _ " type, match[0]," & @CRLF & _ " 'score', score," & @CRLF & _ " 'type', type," & @CRLF & _ " 'match', search" & @CRLF & _ " );" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Perform search on dashboard tags." & @CRLF & _ " * @param {string} search The text to search." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard to perform search on." & @CRLF & _ " * @param {boolean} isFirstSearch" & @CRLF & _ " * @return {?SearchboxForDashboards.SearchResultComponent} The search match" & @CRLF & _ " * component." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doTagSearch_ = function(search, dashboard," & @CRLF & _ " isFirstSearch) {" & @CRLF & _ " if (!('tags' in dashboard)) {" & @CRLF & _ " return null;" & @CRLF & _ " }" & @CRLF & _ " var tagMatches = dashboard.tags.map(function(tag) {" & @CRLF & _ " return this.doTextSearch_(search, tag, isFirstSearch," & @CRLF & _ " SearchboxForDashboards.ComponentType.TAG);" & @CRLF & _ " }, this);" & @CRLF & _ "" & @CRLF & _ " var tagMatches = [];" & @CRLF & _ " var groups = goog.iter.groupBy(tagMatches," & @CRLF & _ " function(tagMatch) { return tagMatch.match; });" & @CRLF & _ "" & @CRLF & _ " var scores = [];" & @CRLF & _ " var score = 0;" & @CRLF & _ " var iterLeft = true;" & @CRLF & _ " while (iterLeft) {" & @CRLF & _ " try {" & @CRLF & _ " var matchTup = groups.next();" & @CRLF & _ " var key = matchTup[0];" & @CRLF & _ " var matches = matchTup[1];" & @CRLF & _ " var numMatches = matches.length;" & @CRLF & _ " var scores = matches.map(function(match) { return match.score; })" & @CRLF & _ " .reduce(function(a, b) { return a + b; }, 0);" & @CRLF & _ " var average = scores / numMatches;" & @CRLF & _ " // numMatches + 1 because the score for one should not be zero" & @CRLF & _ " // have to do log because too many dups for sqrt to make sense" & @CRLF & _ " score += (average * Math.log(numMatches + 1));" & @CRLF & _ " } catch (e) {" & @CRLF & _ " // goog.iter throws exception at the end rather than having a flag" & @CRLF & _ " // to check" & @CRLF & _ " iterLeft = false;" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " return {" & @CRLF & _ " score: score," & @CRLF & _ " type: SearchboxForDashboards.ComponentType.TAG," & @CRLF & _ " match: search" & @CRLF & _ " };" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @param {string} search The text to search for." & @CRLF & _ " * @param {!Array<!smb.model.Dashboard>} dashboards The dashboards to search" & @CRLF & _ " * over." & @CRLF & _ " * @return {!Array<!SearchResultStruct>} The results, sorted." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.doSearch_ = function(search, dashboards) {" & @CRLF & _ " var scoreStructs = dashboards.map(function(dashboard) {" & @CRLF & _ " return this.doDashboardSearch_(search, dashboard, true, true);" & @CRLF & _ " }, this);" & @CRLF & _ " return scoreStructs" & @CRLF & _ " .filter(function(struct) { return struct.score > 0; }, this)" & @CRLF & _ " .sort(function(aStruct, bStruct) {" & @CRLF & _ " return bStruct.score - aStruct.score;" & @CRLF & _ " });" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Updates the autocomplete results, showing the appropriate amount for the" & @CRLF & _ " * current search text." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.updateAutoComplete = function() {" & @CRLF & _ " var dashboards = this.navigationService_.getSearchableDashboards();" & @CRLF & _ " if (!dashboards) return;" & @CRLF & _ " var searchResults = this.doSearch_(this.search, dashboards);" & @CRLF & _ " var searchResultsShow = searchResults.length > 0;" & @CRLF & _ "" & @CRLF & _ " this.searchResults = searchResults;" & @CRLF & _ " this.saveAutoCompleteEvent_();" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Logs autocomplete search." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.saveAutoCompleteEvent_ = function() {" & @CRLF & _ " var urlQuery = this.location_.url();" & @CRLF & _ " // @see onlinesales.revenueprograms.sas.discovery.server.services.UserEventProvider" & @CRLF & _ " var endpoint = this.getUserEventResource_('persist');" & @CRLF & _ " var evnt = {" & @CRLF & _ " type: User.Event.SEARCH," & @CRLF & _ " urlQuery: urlQuery," & @CRLF & _ " search: this.search," & @CRLF & _ " session: smbuser.session" & @CRLF & _ " };" & @CRLF & _ " endpoint.save(evnt);" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Logs search result click." & @CRLF & _ " * @param {number} dashboardId the id of the relavant dashboard" & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.saveSearchResultClick_ = function(dashboardId) {" & @CRLF & _ " var urlQuery = this.location_.url();" & @CRLF & _ " // @see onlinesales.revenueprograms.sas.discovery.server.services.UserEventProvider" & @CRLF & _ " var endpoint = this.getUserEventResource_('persist');" & @CRLF & _ " var evnt = {" & @CRLF & _ " dashboardId: dashboardId," & @CRLF & _ " type: User.Event.SEARCH_CLICK," & @CRLF & _ " urlQuery: urlQuery," & @CRLF & _ " search: this.search," & @CRLF & _ " session: smbuser.session" & @CRLF & _ " };" & @CRLF & _ " endpoint.save(evnt);" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @param {string} action The action path for which to get endpoint." & @CRLF & _ " * @return {!ngResource} Angular resource for the action on user events." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.getUserEventResource_ = function(action) {" & @CRLF & _ " return this.resource_(" & @CRLF & _ " goog.string.format('%s/%s', User.EVENT_ENDPOINT, action));" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Currently returns the arguments, here because of past and potentially" & @CRLF & _ " * future formatting." & @CRLF & _ " * @param {string} tag The tag string." & @CRLF & _ " * @return {string} the tag display text" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.getTagDisplayText = goog.functions.identity;" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Gets the class for the given tag." & @CRLF & _ " * @param {string} tag The tag." & @CRLF & _ " * @return {string} The class name." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.getTagDisplayClass = function(tag) {" & @CRLF & _ " if (tag) {" & @CRLF & _ " var strArr = tag.split(':');" & @CRLF & _ " if (strArr.length == 2) {" & @CRLF & _ " return goog.string.format('tags-style-%s', strArr[0]);" & @CRLF & _ " } else {" & @CRLF & _ " return '';" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " return '';" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Goes to the search results page, if that feature is enabled." & @CRLF & _ " *" & @CRLF & _ " * @param {!jQuery.Event|!JQLite.Event} evt The fired event on keypress." & @CRLF & _ " *" & @CRLF & _ " * @export" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.searchBoxKeypressed = function(evt) {" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Handler for clicking search result item. Navigates to the dashboard." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard selection clicked." & @CRLF & _ " * @param {!jQuery.Event|!JQLite.Event} $event The event for the click." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.resultItemClicked = function(dashboard, $event) {" & @CRLF & _ " $event.stopPropagation();" & @CRLF & _ " this.saveSearchResultClick_(dashboard.id);" & @CRLF & _ " this.navigateToDashboard_(dashboard);" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Navigates to the given dashboard." & @CRLF & _ " * @param {!smb.model.Dashboard} dashboard The dashboard to navigate to." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.navigateToDashboard_ = function(dashboard) {" & @CRLF & _ " this.reset_();" & @CRLF & _ " this.location_.search({});" & @CRLF & _ " this.location_.path(dashboard.navigationURLPath);" & @CRLF & _ " this.route_.reload();" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @param {!SearchboxForDashboards.SearchResultStruct} resultObj Representation of the" & @CRLF & _ " * search result." & @CRLF & _ " * @return {?string} The title text for the search result, if there is any." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.getTitleText = function(resultObj) {" & @CRLF & _ " var dash = resultObj.dashboard;" & @CRLF & _ " return dash.titleDisplayText || dash.menuDisplayText;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @param {!SearchboxForDashboards.SearchResultStruct} resultObj Representation of the" & @CRLF & _ " * search result." & @CRLF & _ " * @return {string} The description text for the search result." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.getDescriptionText = function(resultObj) {" & @CRLF & _ " return resultObj.dashboard.flatDescription;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * @return {boolean} Whether to show the search box on this page." & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.shouldShowResultBox = function() {" & @CRLF & _ " // Shows when it is active, there are results, and there is a search" & @CRLF & _ " return this.scope_.active && !this.hasNoSearchResults_() &&" & @CRLF & _ " this.search.length > 0;" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Sets the search text to the empty string." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.clearSearchBoxText_ = function() {" & @CRLF & _ " this.search = '';" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Sets the search results to an empty array." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.clearSearchResults_ = function() {" & @CRLF & _ " this.searchResults = [];" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "/**" & @CRLF & _ " * Reverts to initial state." & @CRLF & _ " * @private" & @CRLF & _ " */" & @CRLF & _ "SearchboxForDashboards.prototype.reset_ = function() {" & @CRLF & _ " this.clearSearchBoxText_();" & @CRLF & _ " this.clearSearchResults_();" & @CRLF & _ "};" & @CRLF & _ "" & @CRLF & _ "}); // goog.scope" & @CRLF & _ "" Local $sSubst = "($1) => $2" Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst) MsgBox($MB_SYSTEMMODAL, "Result", $sResult)

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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm