CODE:  var searchedTerm = "test"; var returnedString = "National testing Plant testers"; var replacedString = returnedString.replace(/\searchedTerm/g, '&lt;span class="highlight"&gt;'+searchedTerm+'&lt;/span&gt;');   In other words I'm after replacing a searched string, from a returned longer string, to highlight wherever the searched string matched the returned one. Keeping in mind to highlight if it matches more than once in the same returned string aka global.
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?
I'm trying to write a small script to change the current directory to my project directory:  #!/bin/bash cd /home/tree/projects/java   I saved this file as proj, added execute permission with chmod, and copied it to /usr/bin. When I call it by: proj, it does nothing. What am I doing wrong? What's the recommended way to move a VirtualBox VM to another computer? I use VirtualBox 4.1.x on my Ubuntu machine and I’ve set up several virtual machines. Since there are several ways one can move a virtual machine in VirtualBox to another computer, I was wondering which one is the recommended way:   Use the “Import/Export utility.” Copy the entire virtual machine folder, containing the .vdi and .vbox files. Clone the VDI using “Virtual Media Manager” and then recreate a VM on the target machine but using the cloned VDI as the hard disk.   I have successfully used the 1st method several times and it has always worked. The problem is that after exporting and importing, the disk image is transformed into VMDK and not VDI anymore!  The 2nd method is probably the easiest but I’m not sure that simply copying the files will work or not on the target machine. When searching about this method, I found some people had problems in which they had to edit the VirtualBox.xml file to solve it!  At last, there’s the 3rd method, but it requires the extra work of creating a VM similar to the original VM configuration, which is not desirable.  It’s clear from the above explanation that my desired method is the 2nd one, but I need expert advice on this if it works or not. I don't want any XML editing getting in my way!  What’s the best method of safely transferring my VM’s to another computer with VirtualBox? Should I vary input field lengths in a single page checkout form? How to turn off the iOS-style character picker menu In school, I have always seen sets. I was watching a video the other day about functors, and they started talking about a set being a collection, but not vice-versa. I also heard people talking about classes. What is their relation? Some background would be nice.   It has to do with something called Russell's paradox, but I don't know what that is.   I think that the difference between a family and a set is that the former is a function and the latter is a set. Is this right? How do I find (or exclude) all directories and sub-directories matching a certain pattern (in Linux)? Continued fractions I am unable to understand what exactly is critical value.My question here is why do we fail to reject a null hypothesis when the test statistic is within the range of critical value.  What i am trying to ask is what is the property of the critical value that makes the hypothesized value to fall within the range implied by the critical value.  Thanks in advance Running two MySQL servers that use the same data directory Why didn't Gollum grow old and die after he lost the One Ring to Bilbo? Does $x^2 - y^2 = 12345678$ (x,y are integers) have any solutions? I often find myself adding a lot of \textsl{} around inside \emph{} or \textit{} blocks because I find italicized digits to look too "showoffy" and "baroque" and to hinder legibility (I'm using $$ when the number has a mathematical sense, but this situation occurs in less technical texts like CVs, and such.).  Could someone help me write a renewcommand to automate this, or better, a single low level command that makes \emph, \itshape, \textit and friends choose slanted over italic for numbers? I'm not too familiar with the low level latex font selection system nor with a way to detect digits from regular letters.  Edit: MWE of what I need and what I want to avoid  \documentclass{article} \begin{document} He thought: '\emph{Why 1234567890 apples?}' then he realized '\emph{ah yes, he has \textsl{1234567890} childs}' \end{document}   gives:   I find the italicized version (first one) of 2,3,4 and 7 to look especially bad. Prove the equality: $\det\left[\begin{smallmatrix} -2a &a+b &a+c \\ b+a&-2b &b+c \\ c+a&c+b &-2c \end{smallmatrix}\right] = 4(a+b)(b+c)(c+a)$ i have to prove:   $$\begin{vmatrix} -2a &amp;a+b  &amp;a+c \\   b+a&amp;-2b  &amp;b+c \\   c+a&amp;c+b  &amp;-2c  \end{vmatrix} = 4(a+b)(b+c)(c+a)$$   I have tried many calculations between the rows and columns of the determinant to get to the answer i want to solve the exercise however none of them gave me something right. Can someone help? So I have a generic list, and an oldIndex and a newIndex value.  I want to move the item at oldIndex, to newIndex...as simply as possible.  Any suggestions?  Note  The item should be end up between the items at (newIndex - 1) and newIndex before it was removed. I wasn't forcing myself to say anything, or/nor trying to be funny.   "Or" sounds more grammatically correct to me. But "nor" has more Google results. So I'm confused. How do I eliminate reflection on glass? When I take a picture through a window, I often see a reflection on the glass. I have noticed that this occurs mostly when it is dark or overcast outside or it is especially bright on my side of the glass. How can I stop this? I have a small utility that I use to download an MP3 file from a website on a schedule and then builds/updates a podcast XML file which I've added to iTunes.  The text processing that creates/updates the XML file is written in Python. However, I use wget inside a Windows .bat file to download the actual MP3 file. I would prefer to have the entire utility written in Python.  I struggled to find a way to actually download the file in Python, thus why I resorted to using wget.  So, how do I download the file using Python? Knowing the interface of ubuntu and editing them Where are the files for the desktop or the interface that appears on the screen stored? And how can we edit them. How are they programmed?  What programming language is used to built the interfaces? Feedback Request: New Timeline Question View There is an experimental timeline view for questions now available on meta ONLY! (Now working on SO, SF, and SU as well)  This is partially motivated by comments about how difficult it is to follow very active questions which have a lot of activity, and also the feedback on the API which was heavily dominated by "we need to know what happened in this time range" type responses.  It can only be accessed through URL hackery at the moment. To get to it, enter question URLs like so:  https://meta.stackexchange.com/posts/{id}/timeline  This is a chronological timeline of everything that happened on a question, including   initial question ask answers  revisions comments closure, deletion, reopen, undelete, etc votes   all based on when they happened in chronological order.  We are thinking about making this a fourth tab on the question, like so:  Timeline | Oldest | Newest | Votes  Please try it out and provide feedback. It is still a little rough, so we are not looking for highly detailed bug reports, just more general feedback.  Timeline view for this question: How do I rename a domain and preserve SEO? As part of graduating from Area51 and becoming a full fledged site we sometimes change domain names from http://topic.stackexchange.com to http://example.com. Aside from the obvious 301 redirect rules to support existing urls transparently, are there other techniques that would aid in the preservation of SEO?