I am trying to match content on variable c to variable s and selecting the match but all I get is a black bracket or it repeats variable c.  var s = "flowing through a lava occasionally"; var c = "occasionally, sleep, and, oops"; var re = /(?:^|\W)c(\w+)(?!\w)/g, match, matches = []; while (match = re.exec(s)) {   matches.push(match[3]); } console.log(matches);
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 replace all the instances of "B" with "A".  "ABABAB".replace(/B/g, "A");   But I want to do something like this:  String.prototype.replaceAll = function(replaceThis, withThis) {     this.replace(/replaceThis/g, withThis); };   But obviously this will only replace the text "replaceThis"...so how do I pass this variable in to my regex string?
The impression that I got from the  films was that if  was successful, most of the world was going to suffer greatly. Basically everyone would serve Voldemort as slaves or die. So what's the point of serving someone who's probably going to ultimately end up betraying and/or enslaving you? I know the  hated , but is that really enough to justify tearing down Wizard society? Why exactly do the Death Eaters serve Lord Voldemort? Fear? Is the post-Voldemort world not that bad? (I for one welcome our ) Proof of the duality of the dominance order on partitions Could anyone provide me with a nice proof that the  $\leq$ on partitions of an integer $n$ satisfies the following: if $\lambda, \tau$ are 2 partitions of $n$, then $\lambda \leq \tau \Longleftrightarrow \tau &#39; \leq \lambda &#39;$, where $\lambda&#39;$ is the conjugate partition of $\lambda$ (i.e. the transpose of the set of 'dots' which $\lambda$ represents).   I feel like there must be a nice clever and concise/intuitive proof of this, but all I can come up with is an ugly brute force approach based on the definition of sums of the components $\lambda_i$. Could anyone suggest a particularly nice way to obtain this result? Many thanks. What are Alternative's "some" and "many" useful for? How can I change (or remove / reset ) my name on a site in Stack Exchange network? I marinated chicken five days ago in lemon juice, seasoned salt, and garlic powder, is it still safe to cook in the oven? Inside the alley I found myself cornered by unpleasant sights: walls covered with cracks and peeling paint, storm drains clogged with moss, dumpsters overflowing with bags, cans, and rotten trash. Inside the alley I found myself cornered by unpleasant sights: walls covered with cracks and peeling paint; storm drains clogged with moss; dumpsters overflowing with bags, cans, and rotten trash. Inside the alley I found myself cornered by unpleasant sights. Walls covered with cracks and peeling paint. Storm drains clogged with moss. Dumpsters overflowing with bags, cans, and rotten trash.  Or maybe the three of them are orthographically correct in their respective contexts? EDIT (based on dockeryZ's answer): I think second example is right, regardless of the context. Explanation: . How to extract the boundary of a raster image? Axiom of Choice: Where does my argument for proving the axiom of choice fail? Help me understand why this is an axiom, and not a theorem. Is there any way to kill a Thread? Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.? On per-site metas, users are given a rank based on meta participation, and this ranking is seen on the default tab of the users page on each per-site meta. How is this participation numerically calculated to give a ranking? Is it by votes? Something else? Are community wiki posts included in this? My internal storage capacity is running low,  what can I do? Currently, my internal storage is running low on space.    What can I do besides moving applications to the external memory, as to free up more space, but preserve my current applications and avoid uninstalling?  (Some of them won't be moved) Draft watermark image just in a \section Is it possible to have a draft watermark only in a \section?  EDIT:  I have in a document more then one \section, and I need the draftwatermark just in some \section. Unfortunately the section with and without the draftwatermark share the page. For example I want the draftwatermark under the text of just one of these sections A,B,C  \documentclass{article}  \usepackage{kantlipsum} % supply mock text  \begin{document}  \section{A}  \kant[2]  \section{B}  \kant[2-4]  \section{C}  \kant[2]  \end{document} Inspired by  which states limb loss as a recurring theme, I started thinking about the final lightsaber battle. After watching The Force Awakens the second time, I was not sure if      Kylo Ren   lost a limb or just lost his lightsaber. We definitely see      Rey slash at Ren’s right hand.   So knowing that context:      Did Kylo Ren actually lose his arm/hand? How to Convert Persian Digits in variable to English Digits Using Culture? If/When to move to secondary fermentation Digression from   What are the good rules of thumb for determining a. whether to use secondary fermentation at all and b. when to move from primary to secondary.  Preferably any rule of thumb should have both chemical and anecdotal rationale supporting it. Adaline is 100-something years old, and her daughter appears to be 90 years old. Well, Adaline gave birth to her in her mid 20's, and to be precise, she should be 80.   Anyways, Adaline's old lover's son (Ellis) is probably in his late 20's/early 30's. And Adaline has stopped aging at 29, which is pretty close to Ellis. Her old lover is said to be a few years younger than her and still, his son is so young. Also, Adaline could make him believe that she is the daughter of her own old self.   Then,      how can Adaline's real life daughter be so old?   I can't make sense out of this.  Why is it this way? The age pattern of the actors and actresses is inconsistent. It seems to me that the filmmakers have exaggerated some things. How do you type a single backslash, code-formatted, in a comment? Is there a way to type something in a comment that renders like this?     You'll need to escape it with a backslash - that is, the \ character.   I've tried various combinations, but a single backslash formatted as code seems to be impossible. Can this be fixed, or can I be enlightened please?  And to clarify: I expect this:  You'll need to escape it with a backslash - that is, the `\\` character.   to work properly, but it doesn't. Instead, one backslash escapes the ` and I'm left with a mess. When you call the object.__repr__() method in Python you get something like this back:    &lt;__main__.Test object at 0x2aba1c0cf890&gt;     Is there any way to get a hold of the memory address if you overload __repr__(), other then calling super(Class, obj).__repr__() and regexing it out? Remap Caps Lock to Ctrl-b pgAdmin to display multiple result sets