How to escape regular expression in javascript? [duplicate]

How to escape regular expression in javascript? [duplicate]

This question already has an answer here: Is there a RegExp.escape function in Javascript? 12 answers I have code like:pattern = 'arrayname[1]'; // fet

C# variance problem: Assigning List as List

C# variance problem: Assigning List as List

Look at the following example (partially taken from MSDN Blog):class Animal { }class Giraffe : Animal { }static void Main(string[] args){ // Array assignment works, but... Animal[] animals = new Giraffe[10]; // implicit... List

Exception Breakpoint in Xcode

Exception Breakpoint in Xcode

How to add Exception Breakpoint in Xcode?int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); [pool release]; return r

What is a segmentation fault?

What is a segmentation fault?

What is a segmentation fault? Is it different in C and C++? How are segmentation faults and dangling pointers related? 1:Segmentation fault is a specific kind of error caused by accessing memory that “does not belong to you.” It’s a help

Is segmentation fault actual undefined behavior when we refer to a non-static data-member

Is segmentation fault actual undefined behavior when we refer to a non-static data-member

I had read the following rule and I've been trying to write an example, which reflects one.The rule is from 3.8/5 N3797: Before the lifetime of an object has started but after the storage which the object will occupy has been allocated or

When to use double or single quotes in JavaScript?

When to use double or single quotes in JavaScript?

console.log("double"); vs console.log('single');I see more and more JavaScript libraries out there using single quotes when handling strings. What are the reasons to use one over the other? I thought they're pretty much interchangeable.

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created. I've added an Ajax call into this function using jQuery:beforecreat

How to avoid having class data shared among instances?

How to avoid having class data shared among instances?

What I want is this behavior:class a: list = []x = a()y = a()x.list.append(1)y.list.append(2)x.list.append(3)y.list.append(4)print(x.list) # prints [1, 3]print(y.list) # prints [2, 4]Of course, what really happens when I print is:print(x

How do I make a list of data frames?

How do I make a list of data frames?

How do I make a list of data frames and how do I access each of those data frames from the list?For example, how can I put these data frames in a list ?d1 <- data.frame(y1 = c(1, 2, 3), y2 = c(4, 5, 6))d2 <- data.frame(y1 =

Why do partial methods have to be void?

Why do partial methods have to be void?

I am currently learning C# with the book called Beginning Visual C# 2010 and I am in the chapter that discusses different aspects and characteristics of partial methods and classes.To quote the book: Consider at this point why partial meth

Can I avoid running junit tests twice in eclipse when using a TestSuite?

Can I avoid running junit tests twice in eclipse when using a TestSuite?

I need to do some per-suite initialisation (starting a web-server). It is working fine except that when I run all tests in my project in eclipse my tests run twice. My test suite looks a bit like this:@RunWith(Suite.class)@Suite.SuiteClasse

Android custom widget styles: how to put them into a namespace?

Android custom widget styles: how to put them into a namespace?

In the ApiDemos, there is a view example called Gallery1 which declares a custom style in attrs.xml, as such: now, I want to do the same thing for my widgets, but using a different namespace. However, as soon as I replace the android: na

When will OpenCL 1.2 for NVIDIA hardware be available?

When will OpenCL 1.2 for NVIDIA hardware be available?

I would have asked this question on the NVIDIA developer forum but since it's still down maybe someone here can tell me something.Does anybody know if there is already OpenCL 1.2 support in NVIDIAs driver? If not, is it coming soon?I don't

Add Github fork to existing repository

Add Github fork to existing repository

I setup an Octopress project following the given instructions (http://octopress.org/docs/setup/) which have you create a Github repository, and create a local repository on your machine. On your local machine you add a remote to the origina

The most Pythonic way of checking if a value in a dictionary is defined/has zero length

The most Pythonic way of checking if a value in a dictionary is defined/has zero length

Say I have a dictionary, and I want to check if a key is mapped to a nonempty value. One way of doing this would be the len function:mydict = {"key" : "value", "emptykey" : ""}print "True" if len(mydict["key"]) > 0 else "False" # prints t

How do you version your projects?

How do you version your projects?

I understand that Microsoft uses this template when versioning their products: Major.Minor.Build.Revision. Major is changed when the "developers" want to show that there is a big change in the software and backward compatibility cannot be a

DialogFragment in Android with theme

DialogFragment in Android with theme

I'm building my first app in android. I've made a dialogFragment, but it doesn't look nice enough.For having a style and a theme I used this setStyle(DialogFragment.STYLE_NORMAL,0). What I want is that the edge of the fragment to be black l

assigning class variable as default value to class method argument

assigning class variable as default value to class method argument

I would like to build a method inside a class with default values arguments taken from this class. In general I do filtering on some data. Inside my class I have a method where normally I pass vector of data. Sometimes I don't have the vect

Create two Automapper maps between the same two object types

Create two Automapper maps between the same two object types

I am using AutoMapper in a WCF service to return User objects. User has properties such as AccountTeams which itself has child objects. All of the classes have AutoMapper maps.Depending on the WCF OperationContract that is called, I want

Faster 16bit multiplication algorithm for 8-bit MCU

Faster 16bit multiplication algorithm for 8-bit MCU

I'm searching for an algorithm to multiply two integer numbers that is better than the one below. Do you have a good idea about that? (The MCU - AT Tiny 84/85 or similar - where this code runs has no mul/div operator)uint16_t umul16_(uint16

Rotate rectangle around its own center in SVG

Rotate rectangle around its own center in SVG

I have following piece of code : When I translate rectangle without rotation, it is working fine. But when I rotate it, I wanted to rotate it around its center axis point. What should I need to pass to rotate attribute? 1:You just nee

Why does numeric_limits::min return a negative value for int but positive values for float/double?

Why does numeric_limits::min return a negative value for int but positive values for float/double?

Why does numeric_limits::min return a negative value for int, but positive values for e.g. float and double?#include#includeusing namespace std;int main() { cout ::min() ::min() ::min() Output: int: -2147483648 float: 1.17549e-38 double: 2

Root directory in package.json

Root directory in package.json

My question concerns an existing library that I wish to publish as an NPM module. The library is already in use, and currently required via the local file system.How can I specify the root directory of my module's files?If I have a structur

MongoDb near/geonear query with variable distance

MongoDb near/geonear query with variable distance

I would like to execute a query where the distance is a dynamic field from the collection.Example of entries in the collection:{ name:'myName', location: {lat:10, lng:20}, maximumDistance: 10}{ name:'myName2', location: {lat:20, lng:20

Isotope: combination filtering + multiple selection

Isotope: combination filtering + multiple selection

To all jQuery heros out there, I need help! (again) I found similar questions to mine on the internet but there were no answers so far :-/I want to filter a bunch of items with jquery isotope. I adapted the combination filter example from t