i want to replace specific amount of white-spaces from a String at the beginning and i can use   replace(/^\s{2}/g,"");   and it works .but 2 should be changed according to a value of a variable .so i need to construct a new RegExp()  so i used   var lead=2; var regex = new RegExp("\^\\s{" + lead + "}//g"); alert("regex  "+regex);   real output   /^\s{2}\/\/g/   expected output  /^\s{2}/g   could you help me to fix this problem.tnx
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?
Is there a word that means "a span of six months"? That is, I want to connote a stretch of time that lasts half a year, not an event that happens every six months. I would like to know: How come that  $$\sum_{n=1}^\infty n x^n=\frac{x}{(x-1)^2}$$  Why isn't it infinity? No matter how I do it, I always end up with $x = 0, 90, 270$ and $360$. All of those except $270$ is right, but I can't quite figure out how to get the $270$ degrees out of the answer. I've tried using trig identities, I've tried squaring both sides, but I always end up with $$2\sin x\cos x$$ which then leads me to $x = 0, 90, 270, 360$. But $$\sin (270) + \cos (270) = -1$$ so I'm doing something wrong. Help with proof that $\mathbb Z[i]/\langle 1 - i \rangle$ is a field. Why isn't sizeof for a struct equal to the sum of sizeof of each member? Why does the sizeof operator return a size larger for a structure than the total sizes of the structure's members? Often I see code blocks pasted into questions with no formatting, or terrible formatting.  It's sometimes quite a chore to fix these: you have to either manually space out each line, or paste the code into an IDE, format it there, and paste it back.  Could we have a button/function where you could highlight a code block, and it would turn this:  foreach (var i in stuff) { if (i==1) { Whatever(); } }   into this:  foreach (var i in stuff) {   if (i==1) {     Whatever();   } }   I realise the function would have to work differently based on the language in the code block. Perhaps  it could use the same rules as the prettify code.  Also, it wouldn't be a big deal if it gets the language wrong and breaks the code, since you can always just ctrl+z. How to shrink Windows 7 boot partition with unmovable files I have just bought an HP laptop with Windows&nbsp;7 (64 bit). It has a 500&nbsp;GB HDD with three partitions: a small hidden system partition, a 12&nbsp;GiB HP recovery partition, and a 450&nbsp;GiB C: boot partition.  I would like to split this large C: partition into two partitions, leaving only 100&nbsp;GiB for the system, and giving the rest to a new data partition.  Although the Windows built-in Disk Management utility has an option to shrink the bootable partition, it only allows me to shrink it roughly by half, even though only 20&nbsp;GiB on the partition is used. As far as I understand, system unmovable files lie in the middle of the partition, preventing Disk Management utility to do what I want.    And since new HP laptops don't come with OS installation disks (they only allow you to create recovery disks yourself), I can't just repartition HDD and then reinstall OS.  So, is there a way to shrink the C: bootable partition and preserve Windows&nbsp;7 working?  P.S.: I have tried to use the third-party  utility, and after shrinking the partition, Windows&nbsp;7 stopped booting, with a . System recovery didn't work, and I had to do factory recover. Since this is a long process, I would like to avoid doing it again :) So, please, suggest only proven solutions. BASH script to set environment variables not working I've written the following script to set some environment variables when needed.  #!/bin/sh export BASE=/home/develop/trees echo $BASE export PATH=$PATH:$BASE echo $PATH   Below the command and the results I can see on my terminal: the script runs, but the variables are not set at the end.  ~$: ./script.sh /home/develop/trees /bin:......:/home/develop/trees ~$: echo $BASE  ~$:    What's wrong? Thanks in advance. Mirko $|G|>2$ implies $G$ has non trivial automorphism Electrical potential energy stored in vacumm for a single point charge? I have come to know the electrostatic potential energy in vacuum is given by $${\frac{1}{2}} \epsilon_0\int d^3x {E^2} $$ and this energy  is due to the mutual electrostatic coulomb potential energy. So only a single point charge in space also contributes to some electrostatic potential energy according to $${\frac{1}{2}} \epsilon_0 \int d^3x {E^2} $$  as due to a single point charge also we have an electric field at every point in space. Now I am not getting it physically, why should there be any Coulomb energy in this case as there is no other charge to provide the electrostatic coulomb potential energy? Having different horizontally  distributed equations inside an align environment, only lines are numbered, but not individual equations.    How can the left equations be numbered using subequations? See also the question   \documentclass{article} \usepackage{amsmath} \begin{document}   \begin{subequations}     \begin{align}        %\label{a}         a &amp;= a ,&amp;       \label{b}         b &amp;= b ,\\       %\label{c}         c &amp;= c ,&amp;       \label{d}       d &amp;= d .     \end{align}   \end{subequations} \end{document}     The solution should be able to either:    attach a label to the left equations, or modify the labels on the right to read (1a,b) and (1c,d)    I couldn't find anything in the documentation of amsmath or other packages. What is the best way to copy text to the clipboard (multi-browser)? I have tried: function copyToClipboard(text) {     if (window.clipboardData) { // Internet Explorer         window.clipboardData.setData(&quot;Text&quot;, text);     } else {         unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalXPConnect&quot;);         const clipboardHelper = Components.classes[&quot;@mozilla.org/widget/clipboardhelper;1&quot;].getService(Components.interfaces.nsIClipboardHelper);         clipboardHelper.copyString(text);     } }  But in Internet Explorer it gives a syntax error. In Firefox, it says unsafeWindow is not defined. A nice trick without using : Border with a transparent centred arrow Hovering over featured moves the questions down a bit When I hover over featured tab, both on the front page and in questions, the questions move down by one pixel. Here's a small screen capture demonstrating the issue:        I see it in Chrome 34 and Opera 20, but I don't see it on IE11 or Firefox 28. I'm new to Ubuntu, it looks like it is better than Windows. Last day I tried to install Kget (the download manager) but during the process my computer suddenly stopped working. So I had to switch it off. After I logged into Ubuntu again I can't install any program. The Ubuntu Software Center says:  Items cannot be installed or removed until package catalog is repaired. Do you want to repair it now?   After I clicked repair it says (after few seconds):  Package operation fails - The installation or removal of a software package failed   I've tried several times, but the same problem occurred. Can anyone tell me a solution for this problem? How to obtain and use the .bbl file in my tex document for ArXiv submission? I am submitting my first article to ArXiv and in the instructions they specify I have to include the .bbl file. Their instructions are:  "We do not run BibTeX in the auto-TeXing procedure. If you use it, include in your submission the .bbl file that BibTeX produces on your own machine; otherwise your references will not come out correctly. We do not run BibTeX because the .bib database files can be quite large, and the only thing necessary to resolve the references for a given paper is the .bbl file. The name of the .bbl file must match the name of the main .tex file for the system to process the references correctly."  My knowledge of LaTeX is basic, and I have not heard of .bbl file before. I am using TeXmaker. I have my tex file and my bib file. So what do I exactly do to obtain the .bbf file correctly and submit the article?  Thanks a lot! If $f(0)=0$ and $f'$ is increasing, then $\frac{f(x)}{x}$ is increasing. Is there any reason to not complete the game? Would there be anything in Skyrim where you wouldn't want to complete the main story? (Yes, I know the game continues after that)  Like something you can no longer access, or do after beating the game? Does English have any singularia tantum besides mass nouns? and  are, respectively, nouns that have only a singular form and nouns that have only a plural form.  In English, we have a handful of pluralia tantum that are mass nouns which take the plural form (e.g. "riches" and "remains"), a whole load of pluralia tantum that refer to things that come in pairs (e.g. "trousers", "sunglasses", "knickers", or "scissors"), and at least one plurale tantum that fits into neither of the above categories ("clothes", meaning multiple items of clothing - it's clear what the hypothetical singular "clothe" would mean, yet it mysteriously isn't a word). Singularia tantum, on the other hand, seem less varied. As far as I can tell, they are all  - things like "information", "milk", and "racism".  One can imagine there being a singulare tantum that is not a mass noun. For example, we can imagine an alternate universe in which it is still correct English to talk about "a dog", but talking about "dogs" in the plural is incorrect and funny in the same way that it is incorrect and funny to talk about a "scissor". It might seem unintuitive to think that such a noun even could exist - surely, if it is not a mass noun, then people would just pluralise it with an "s" on the end like most other words? But the converse argument could just as well be made about countable pluralia tantum, and I still cannot go to a shop and buy a "clothe". Hence my question: do we have any such countable singularia tantum in the language? Have we in the past? Map a network drive to be used by a service Suppose some Windows service uses code that wants mapped network drives and no UNC paths. How can I make the drive mapping available to the service's session when the service is started? Logging in as the service user and creating a persistent mapping will not establish the mapping in the context of the actual service.