So for example:  function(input){     var testVar = input;     string = ...     string.replace(/ReGeX + testVar + ReGeX/, "replacement") }   But this is of course not working :) Is there any way to do this?
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?
Do you need to take the Hide action when you are Invisible, make no noise and leave no traces? The Situation: Lets say you are under the effect of Invisibility.  An invisible creature is impossible to see without the aid of magic or a special sense. For the purpose of hiding, the creature is heavily obscured. The creature's location can be detected by any noise it makes or any tracks it leaves.  And you are wearing the Boots of Elvenkind  While you wear these boots, your steps make no sound, regardless of the surface you are moving across. You also have advantage on Dexterity (Stealth) checks that rely on moving silently.  Now your groups ranger or druid casts Pass Without Trace on you.  [...] can’t be tracked except by magical means. A creature that receives this bonus leaves behind no tracks or other traces of its passage.  My Question(s): I know that when you are Invisible and you did not hide, you are still detectable because of the noise and the track you leave behind. But the Boots of Elvenkind and Pass Without Trace take care of that. So:  Are you still required to take the hide action in this situation if you don't want enemies to know your location/presence? If so, why? What gives away your location? If not and you are under the effect of greater Invisibility do you get the benefits of &quot;Unseen Attackers and Targets&quot; for every attack you make when you move between attacks? (You would give away your location, but are not detectable, so completely hidden again when you move) Reading and searching long man pages I know in php you are able to make a call like:  $function_name = 'hello'; $function_name();  function hello() { echo 'hello'; }   Is this possible in .Net? calculation of $\int_{0}^{1}\tan^{-1}(1-x+x^2)dx$ Compute the definite integral   $$ \int_{0}^{1}\tan^{-1}(1-x+x^2)\,dx $$   Failed Attempt:  Let $1-x+x^2=t$. Then  $$ \begin{align} (2x-1)\,dx &amp;= dt\\ dx &amp;= \frac{1}{(2x-1)}dt \end{align} $$  Changing the limits of integration, we get  $$\int_{1}^{1}\tan^{-1}(t)\cdot \frac{1}{(2x-1)}dt = \int_{1}^{1}\tan^{-1}(t)\cdot f(t)dt = 0 $$  where $f(t)=\frac{1}{(2x-1)}$.  Is it true that $\int_{a}^{a}f(x)dx = 0$? If not, then where have I made a mistake in my attempted solution? Show that if $\sup\big\{\sum\lvert\, f(a)\rvert\big\}  0\}$ is countable. Let $f:A \to \mathbb R$ and suppose that $$ \sup\Big\{\sum_{a\in F}\lvert\, f(a)\rvert :  F\text{ is finite subset of }A\Big\} &lt; \infty $$ then the set $\{ a \in A : f(a) &gt; 0\}$ is countable.  My try: Define these element of ${ a ∈ A : f(a) &gt; 0}$, then $∑_{n=1}^\infty\lvert\, f(a_n)\rvert$ is determined, regardless of the method of arrangement. Electrostatics and tv screens I had this "almost bonus" question on the final in Group Theory recently: prove that there is no such group $G$ which would satisfy Aut$(G)\cong \mathbb{Z}_n$, where $n$ is an odd integer. I don't have much certainty if this proof is OK, and one's opinion would be appreciated.  Here's my attempt:     Suppose that there exists such a group $G$ that satisfies the above condition. Since $\mathbb{Z}_n$ is cyclic, Aut$(G)$ is also cyclic and $G$ is abelian, which implies that Inn$(G)\cong \{e\}$. Thus Aut$(G)=$Out$(G)$. (I don't think this fact is important here though). Now, since an automorphism sends a generator to a generator, and since each automorphism is completely determined by such mapping, |Aut($G$)| must be of factorial order. But an integer factorial is always even. However, $|\mathbb{Z}_n|$ is odd, which is a contradiction. Therefore, no such $G$ exists.   I'm afraid that my proof is not very nice, but at least a genuine attempt was made. When will my device get the Android 5.0 update (Lollipop)? Post a Form to Popup window not to the parent What is the measure of the set of numbers in $[0,1]$ whose decimal expansions do not contain $5$? I am running 12.04 LTS. It's a pretty default installation and is the only OS on this machine.  I have two users one has administrator rights the other does not. I accidentally removed administrator rights from the "admin" user.  I tried to  but that requires reaching GRUB during boot but I cannot get there because my /etc/default/grub has GRUB_HIDDEN_TIMEOUT=0 and changing that to a positive integer requires admin privileges to save the changes and run sudo update-grub.  Should I boot from LiveCD? The  discouraged my a bit. Right now all I have handy is an install DVD from 11.10, but that did not help me much.  Not sure what to do now.  Any suggestions?  NOTE: 12.04 does not have an admin group and I have not enabled root Can I change directory to a Windows drive in Ubuntu Bash on WSL? I am a super newbie for Ubuntu and basically need Ubuntu for a Python package.  I would like to run a Python file in say e:/username/folder1/folder2/python.py. I tried every method online and the only reply is bash: cd./e: No such file or directory. I am not sure whether it is because of the bash windows or virtualenv.  When I use bash on Ubuntu on Windows, ls, it says VIRTUALENV_DIR. cd, it says /home/username. The cd .. etc changes the directory a little, but not another drive, nor the folder I would like it to find. What makes someone deserving of a Ph.D.? Few days back while attending a thesis defense, one Professor was asking the defender why does he think, he deserves the degree. I was wondering since then, is there really any general answer for that? or the answer should be given describing my own work and then emphasis them how it is important for research field?  I asked the question here to know your opinion about it and to list down what could be the possible answers to this question. Proving $\int_{0}^{\infty} \mathrm{e}^{-x^2} dx = \frac{\sqrt \pi}{2}$ Where did the "play on realms" option go? My Minecraft app now only has the option of "play" and there is no "play on realms" to be found!  I downloaded - and paid for - the multiplayer app, but there doesn't seem to be a way to get to any realms on that app either. command not found and syntax error near unexpected token I have this script to divide a file over a 100000 or even more in 50000 lines.  desc()                                                     {                                                       echo $1 $2|awk '{d=$1;}                                 BEGIN {a=1;b=0}                                            { f=d"0"a;                                                while ((getline x&lt;d)&gt;0)                                   { print x&gt;&gt;f".txt"                                        if (b++&gt;=50000)                                            {                                                         close(f);b=0;a++;f=(a&lt;10)?d"0"a:f=d""a                }                                                  }                                                   }                                                   END {print "Terminado ... ! "}'                         }                                                      if [ -f $1 ]; then                                              desc $1 $2                                      fi                                                        When I execute it I got this error message:  sh-3.2$ parte.sh pa.txt                                  : command not found                                      '/parte.sh: line 2: syntax error near unexpected token ` '/parte.sh: line 2: `desc()                              sh-3.2$                                                    Can anyone help to solve it? How to add an image to a JPanel? I have a  to which I'd like to add JPEG and PNG images that I generate on the fly.  All the examples I've seen so far in the , specially in the  use ImageIcons.  I'm generating these images as byte arrays, and they are usually larger than the common icon they use in the examples, at 640x480.   Is there any (performance or other) problem in using the ImageIcon class to display an image that size in a JPanel? What's the usual way of doing it? How to add an image to a JPanel without using the ImageIcon class?   Edit: A more careful examination of the tutorials and the API shows that you cannot add an ImageIcon directly to a JPanel. Instead, they achieve the same effect by setting the image as an icon of a JLabel. This just doesn't feel right... Why does the command shuf file > file leave an empty file, but similar commands do not? I know this is sort of a duplicate of another question () but I wanted to expand on the question in response to the answers given.  The command  shuf example.txt &gt; example.txt  Returns a blank file, because the shell truncates the file before shuffling it, leaving only a blank file to shuffle. However,  cat example.txt | shuf &gt; example.txt  will produce a shuffled file as expected.  Why does the pipeline method work when the simple redirection doesn't? If the file is truncated before the commands are run, shouldn't the second method also leave an empty file? In AVR datasheets under the Electrical Characteristics section you will typically find a graph like this (this one is from the ATMega328):    I've seen designs that seem to "work" but operate outside the shaded envelope. Specifically, I've seen 3.3V (Arduino) designs that run the clock from an external 16MHz crystal. Clearly, this is out of spec. What are the practical negative consequences of running outside this envelope? How do you teleport a certain player to spawn after they win a 1v1 I managed a KitPvP server in Minecraft and everything works fine except when players wants to duel each other. They get sent to a room where they will be dueling. The main problem is when the winner wins, I have no idea how to teleport them back to spawn.