This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 3 years ago.
I'm not sure what the code below means. I know how to use match, but I'm not sure on what the brackets and "^" signs mean. Is there a website to where I can understand what all you can do with match?
var imagesURL;
imagesURL = html.match(/CapImg[^"']*/g);
match is usually used along with RegExp to search through a data for a particular value or pattern of values. ..
You should rather go and read about JavaScript RegExp (or Regular Expression).
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Related
This question already has answers here:
Regex Until But Not Including
(3 answers)
Closed 3 years ago.
I'm currently struggling with finding a way to extract domain names in urls.
My strings
xyz.weam.com
we2.wal.com
abc.workwork.google.net
I would like it to look for (com|org|net) and take the string before the match including the match until it hits the first (.) going backwards.
I have tried different combinations of lookbehind and positive lookahead but I was never able to make it stop at the right dot (.).
Thanks for the answers guys and especially to Aaron, his answer worked perfectly.
His Regex did the trick.
\.([^.]+).(?:com|net|org)$
This question already has answers here:
Match only unicode letters
(3 answers)
Closed 4 years ago.
I have this PHP regex:
/^[\p{L}\p{M}]+[\p{L}\p{M}\-\s]*$/u
and I want to convert it to jQuery. I tried multiple solutions that I found online, but nothing really worked. I tried using
new RegExp("/^[\p{L}\p{M}]+[\p{L}\p{M}\-\s]*$/u");
but that didn't help.
This is because \p{L} and \p{M} don't exist in the JavaScript RegEx engine. This answer provides solutions for matching Unicode categories: https://stackoverflow.com/a/26659285/1920035
This question already has answers here:
What does this symbol mean in JavaScript?
(1 answer)
What does this `…${…}…` code in the node docs mean? [duplicate]
(1 answer)
Closed 5 years ago.
I'm a bit of a beginner still and keep coming across this in code:
${Math.round(newProps.percent)}% surrounded by backticks
or
${currentBillingStartDate} surrounded by backticks and not using the percent.
I'd like to understand when it should be used and why.
The percent sign is just a character that is meant to be interpolated with the expression inside the ${variable}. The result would be a string that looks like "55%"
This question already has answers here:
How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?
(15 answers)
Closed 6 years ago.
I want to find each youtube link in a page. I found on StackOverflow some regex i modified but when i have a html code with two youtube linq the result is one match like
youtube.com?v=videoid<div></div>youtube.com?v=videoid2
I want to get each youtube link only.
My regex is :
/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([\w|-|_]{11})/
Can someone help me please?
Thanks and sorry for bad english.
try to add 'g' modifier at the end of the regular expression like so:
/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([\w|-|_]{11})/g
That means globally (get all matches)
This question already has answers here:
Regular expression for first and last name
(28 answers)
Regex for names
(27 answers)
Closed 8 years ago.
I'm creating a web store and I need to validate inputs with JavaScripts so the user doesn't have to submit a form to be given the PHP errors (although I'm also validating the form with PHP).
What I came up with is the following regex:
/^[a-zA-Z]+$/
But the above regex would only allow alpha characters whereas I also want to allow characters such as ' and - since obviously names may also contain these two characters. My question is, how to make a regex to allow alpha characaters AND the two characters above.
Besides that I also have one more question which just came in my mind, characters such as ă will pass the above validation ?
By adding them to your character group like so
/^[a-zA-Z'-]+$/