RegExp#exec
and String#match
JS-D00710560 ? q.trim(a)
10561 : "") ||
10562 window.location.href ||
10563 "") && (n.match(/^([^#]+)/) || [])[1]),10564 (o =
10565 /(MSIE|Trident)/.test(navigator.userAgent || "") &&
10566 /^https/i.test(window.location.href || "")
10230 updateKey = response.url.match(/[?|&]update=([^&]+)($|&)/)
10231 ? RegExp.$1
10232 : null;
10233 addElement = response.url.match(/[?|&]add_element=([^&]+)($|&)/)10234 ? RegExp.$1
10235 : null;
10236 $(".webform-ajax-refresh").trigger("click");
10227 a.pathname === window.location.pathname &&
10228 $(".webform-ajax-refresh").length
10229 ) {
10230 updateKey = response.url.match(/[?|&]update=([^&]+)($|&)/)10231 ? RegExp.$1
10232 : null;
10233 addElement = response.url.match(/[?|&]add_element=([^&]+)($|&)/)
10214 // @see https://stackoverflow.com/questions/6944744/javascript-get-portion-of-url-path
10215 var a = document.createElement("a");
10216 a.href = response.url;
10217 var forceReload = response.url.match(/\?reload=([^&]+)($|&)/)10218 ? RegExp.$1
10219 : null;
10220 if (forceReload) {
6603 });
6604 } else if (
6605 drupalSettings.google_analytics.trackOutbound &&
6606 this.href.match(/^\w+:\/\//i) 6607 ) {
6608 if (
6609 drupalSettings.google_analytics.trackDomainMode !== 2 ||
RegExp#exec
and String#match
should only be used when we need to use the parts of a string that match a specific pattern:
const matches = /[a-zA-Z0-9]+/.exec(string)
for (const match of matches) {
processMatch(match)
}
If you only want to know whether a string matches a particular pattern, RegExp#test
is a faster alternative.
const matches = str.match(/[a-zA-Z0-9]/) ? process(str) : process("default-str");
const strMatchesPattern = !!str.match(/regex/)
const regexp = new RegExp("[a-zA-Z0-9]*")
if (regexp.exec(myString)) {
// ...
}
const matches = '/hasTheMagic/'.test(str) ? process(str) : process("default-str");
const strMatchesPattern = /regex/.test(str)
const regexp = new RegExp("[a-zA-Z0-9]*")
if (regexp.test(myString)) {
// ...
}