I have string that is dynamic and need to change along with escape character. Suppose  var key = "Any String"; var term = "^"+key+"^"; var description = description.replace(term,"replacement_string");   it replace only first occurrence and works well.it changes like this:     Lorem ipsum dolor sit amet ^Any String^ and Any String Lorem ipsum dolor sit amet ^Any String^   to     Lorem ipsum dolor sit amet replacement_string and Any String Lorem ipsum dolor sit amet ^Any String^    if I use replace globally then it doesn't work  var key = "Any String"; var term = "/\^"+key+"\^/g"; var description = description.replace(term,"replacement_string");   print like this:     Lorem ipsum dolor sit amet ^Any String^ and Any String Lorem ipsum dolor sit amet ^Any String^   I need to change all occurance of ^Any String^ not if Any String doesn't have ^ then it shouldn't change the word. Result should be like this.     This is a description with replacement_string and Any String also need to change replacement_string
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?
Prevent Serialization of Base Class Review of a proof for De Moivre's theorem using mathematical induction The following is a rigorous proof of De Moivre's theorem by means of mathematical induction. The theorem put simply is that:  Any complex number, $z = a+bi$, on a cartesian plane can be expressed in polar form, where $a=r\cos\theta$ and $b=r\sin\theta$ and $r$ is the absolute distance from the origin to the point $z$. In light of this, the expression for the complex number $z$ in polar form is $z=r(\cos\theta+i\sin\theta)$ In order to find the $n^{th}$ power of $z$, the following rule applies: $$\displaystyle z^n=(r(\cos\theta+i\sin\theta))^n=r^n(\cos n\theta+i\sin n\theta)$$ where $n\in\mathbb N$ (I have confined $n$ to the natural numbers given that I intend on using mathematical induction to prove the theorem.  Base step: We must prove that what is stated is true for $n=1$, hence $$z^1=r^1(\cos 1\cdot\theta+i\sin1\cdot \theta)$$ $$=r(\cos\theta+i\sin\theta)$$ which is true. Next we assume it is true for $n=k$, and therefore proceed to the inductive step. Inductive step: When calculating $z^{n+1}$, it's the same as calculating $z^nz$, hence $$z^{n+1}=(r^n(\cos n\theta + i\sin n\theta))(r(\cos \theta+i\sin \theta))$$ $$=r^nr(\cos n\theta+i\sin n\theta)(\cos\theta +i\sin \theta)$$ $$=r^{n+1}(\cos n\theta\cdot\cos\theta+\cos n\theta \cdot i\sin\theta+i\sin n\theta\cdot\cos\theta+i^2\sin n\theta\cdot\sin\theta)$$ from here, $i^2=-1$, and therefore $+i^2\sin n\theta\cdot\sin\theta$ becomes $-\sin n\theta\cdot\sin\theta$. In addition to this, the following trigonometric identities will be used: $$\sin(n\theta + \theta) = \sin n\theta\cdot\cos\theta+\cos n\theta\cdot\sin\theta$$ $$or$$ $$k\sin(n \theta+\theta)=k\sin n \theta\cdot\cos \theta + \cos n\theta\cdot k\sin\theta$$ $$and$$ $$\cos(n \theta + \theta)=\cos n\theta\cdot\cos\theta-\sin n\theta\cdot\sin\theta$$ by using these, the original equation has now become $$=r^{n+1}(\cos(n \theta + \theta) + i\sin(n \theta + \theta))$$ then, after factoring out $\theta$, the theorem becomes $$=r^{n+1}(\cos((n+1)\theta)+i\sin((n+1)\theta))$$ which completes the proof. Question: is this proof correct all the way through? Or have I missed any conditions? If all is well in the case of this proof, could somebody aid me in proving it for $\{n|n\in\mathbb R,n\geq1\}$ db_update Query Issue I am using ubercart guest checkout module. I am able to submit  the order as guest etc works fine.   After Reviewing the order and submitting it throws me this error   Recoverable fatal error: Argument 2 passed to db_query() must be an array, string given, called in /var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module on line 263 and defined in db_query() (line 2342 of /var/www/html/dev.demo.net/includes/database/database.inc).   This is the query which is causing that issue    db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account-&gt;uid);   I tried to change this query like this  db_update('users') -&gt;fields(array(     'name' =&gt; $name,     'mail' =&gt; $mail )) -&gt;condition('uid',$account-&gt;uid,'=')        -&gt;execute();   still no luck, it throws me same above specified error.    How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance. Algebraic Proof that $\sum\limits_{i=0}^n \binom{n}{i}=2^n$ I'm well aware of the combinatorial variant of the proof, i.e. noting that each formula is a different representation for the number of subsets of a set of $n$ elements. I'm curious if there's a series of algebraic manipulations that can lead from $\sum\limits_{i=0}^n \binom{n}{i}$ to $2^n$. In his first lesson (transcripted in "Tips on Physics"), Feynman talks about math for physicists in a very cool and practical way. And at the end of the section he talks something like "so the first thing to do is to learn to learn derivative, integral and algebra" (I don't know how much precise I'm being because I've read it in Portuguese). I would to know if there is some book that deals with math as Feynman did it in this lesson (respecting formalities, but teaching how to use the practical rules)? Also, someone have any recommendations for algebra book (college level)? Speed of light travel I am a graduate student in mathematics who would like to learn some classical mechanics. However, there is one caveat: I am not interested in the standard coordinate approach. I can't help but think of the fields that arise in physics as sections of vector bundles (or maybe principal bundles) and would love an approach to classical mechanics or what have you that took advantage of this.  Now for the questions:   Is there a text book you would recommend that phrases the constructions in classical mechanics via bundles without an appeal to transition functions?   What are the drawbacks to this approach other than the fact that it makes computations less doable? (if it does that)   Are there benefits to thinking about things this way, ie would it be of benefit to someone attempting to learn this material to do it this way? What are the numbers / symbols to the right of my reputation counter? Why do we say "Eastern Europe" but "East Asia"? I am running Ubuntu 14.04.2 and I want to format my disk for another operating system (Windows 10).  My desire to do this stems from a recent problem I have been having with installing the new OS. I try to boot from a live DVD (which I have confirmed is working), but my computer does enter the Windows 10 installation setup.  So, I am hoping that completely wiping the disk will solve this issue. Ideally, I want to do this with my only resources being Ubuntu and an internet connection. I can't connect the hard drive to another computer, and it would be difficult for me to have to burn a disc for any reason.  Thank you. I am using ArcGIS Desktop 10.1.   I am trying to find the location of the highest value pixel in my Direct Solar Radiation Raster. I can see the extent of the data in my raster but don't know where the highest value pertains to.   Is there a way to simply select pixel with highest value or create a point at highest value? Well, I have come to understand persons with the following traits will be usually be Sorted to Slytherin   Resourcefulness  Cunning Ambition Leadership Qualities Self-Preservation Determination  Cleverness Fraternity  Power   On which trait(s) was Snape Sorted into Slytherin?  One more point: Lily Evans was Sorted before Snape, and when she was placed in Gryffindor, obviously Snape wanted to be in Gryffindor too, because Lily is his only friend.   So why is he Sorted into Slytherin? Is there a stronger reason for the Sorting Hat to override his preference and Sort him into Slytherin? Prove that the union of two disjoint countable sets is countable Can comments be used in JSON? Why and how is the  of a matrix in $M_3(\mathbb C)$ fully determined by its characteristic and minimal polynomials? And why does it fail for $n &gt;3$?   Thanks. In classical logic, why is $(p\Rightarrow q)$ True if $p$ is False and $q$ is True? Provided we have this truth table where "$p\implies q$" means "if $p$ then $q$":  $$\begin{array}{|c|c|c|} \hline p&amp;q&amp;p\implies q\\ \hline T&amp;T&amp;T\\ T&amp;F&amp;F\\ F&amp;T&amp;T\\ F&amp;F&amp;T\\\hline \end{array}$$  My understanding is that "$p\implies q$" means "when there is $p$, there is q". The second row in the truth table where $p$ is true and $q$ is false would then contradict "$p\implies q$" because there is no $q$ when $p$ is present.  Why then, does the third row of the truth table not contradict "$p\implies q$"? If $q$ is true when $p$ is false, then $p$ is not a condition of $q$.  I have not taken any logic class so please explain it in layman's terms.       Administrative note. You may experience being directed here even though your question was actually about line 4 of the truth table instead. In that case, see the companion question  And even if your original worry was about line 3, it might be useful to skim the other question anyway; many of the answers to either question attempt to explain both lines. Spoilers Alert!!!      Bran sees that Jon is the son of Lyanna at Tower of Joy.   However, People of the north won't just believe words.  Howland Reed was with Eddard at the tower, Eddard is dead, but Howland could be alive. Even if Howland Reed comes forth and tells Jon's true lineage. It will still be just words.   Why would the people believe the words of a child and an old man? I have GM'd several RPGs before that are not D&amp;D (Fate, Deathwatch, Star Wars). We first tried to play D&amp;D using the 3.5 edition and it went horribly — too many books and too many options with no idea of where to start.  I have been told that 5E takes care of all that and is easier and more fun so I want to try that but I would like a definitive list of what I need.  I expect that the kinds of books we need divide up like this:   Rulebook for me as GM Rulebook for players Fluff for everyone Monster book for me as GM   Links to these would be helpful as we got very confused with the 3.5 books — who should use what books confused us.  What other things do we need to play a campaign? I expect things like:   Dice: what kinds and how many of each kind, roughly. Models and maps. Do we need these? Does 5E need models and a grid or can it be played without (which is preferred)?   Is there anything else that we need that I haven't anticipated? How to remove trailing whitespaces with sed? Prove that $ \sum_{n=0}^\infty \frac{z^{2^n}}{1-z^{2^{n+1}}}=\frac{z}{1-z} $ Show that for $|z|&lt;1$, one have $$ \frac{z}{1-z^2}+\frac{z^2}{1-z^4}+\cdots+\frac{z^{2^n}}{1-z^{2^{n+1}}}+\cdots = \frac{z}{1-z} $$ and $$ \frac{z}{1+z}+\frac{2z^2}{1+z^2}+\cdots+\frac{2^k z^{2^k}}{1+z^{2^k}}+\cdots = \frac{z}{1-z} $$ Use the dyadic expansion of an integer and the fact that $2^{k+1}-1=1+2+2^2+\cdots+2^k$.