What is the problem with this regular expression when I use the global flag and the case insensitive flag? Query is a user generated input. The result should be [true, true].  var query = 'Foo B'; var re = new RegExp(query, 'gi'); v...
I would like to create a String.replaceAll() method in JavaScript and I'm thinking that using a regex would be most terse way to do it.  However, I can't figure out how to pass a variable in to a regex.  I can do this already which will rep...
I want to match a portion of a string using a regular expression and then access that parenthesized substring:  var myString = "something format_abc"; // I want "abc"  var arr = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(myString);  co...
In the regex below, \s denotes a space character.  I imagine the regex parser, is going through the string and sees \ and knows that the next character is special.  But this is not the case as double escapes are required.  Why is this?  var res = n...
How can I use Unicode-aware regular expressions in JavaScript? For example, there should be something akin to \w that can match any code-point in Letters or Marks category (not just the ASCII ones), and hopefully have filters like [[P*]] for punctu...
Is there a way to achieve the equivalent of a negative lookbehind in javascript regular expressions?  I need to match a string that does not start with a specific set of characters.  It seems I am unable to find a regex that does this without faili...
I want a regular expression to check that:  A password contains at least eight characters, including at least one number and  includes both lower and uppercase letters and special characters, for example #, ?, !.  It cannot be your old password or...
How do I split a string with multiple separators in JavaScript?  I'm trying to split on both commas and spaces but, AFAIK, JS's split function only supports one separator....
How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript:  var temp = "This is a string."; alert(temp.count("is")); //should output '2'...
Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year's resolution is to not try and learn regex again - So this yea...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.