I try to create a regex for nr. of decimal of a number and the number of decimal will be pass from variable.  (Ex:  123.4545)-> 4decimals  const regex = 4; const decimalValidation = helpers.regex('decimalValidation',/^\d*(\.\d{1,4})?$/);  //Insted of 4 ,I have to replace with regex const.
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?
Make the search box return results from all StackOverflowian sites? Multiple File Extension Rename with single command I received some important files via mail. There are about 150 files like these. The extensions of the files are named as zip1,zip2,zip3, zip_ etc. I just want to change the extension of these files back to zip using a single command to avoid the manual task of renaming each file. Closing Streams in Java How can I detect inside a TeX file which engine (pdftex/xetex/luatex) is used to compile the file? Is there a LaTeX package that provides this functionality? Lightning tags in beta I came across some lightning tags that are still in beta, ex: lightning:input (Beta) lightning:tabset (Beta) etc  Not sure for how long they were in beta, is it advisable to use them for building UI and deploy to production? Why is black the best emitter? Rounding up to next power of 2 I want to write a function that returns the nearest next power of 2 number. For example if my input is 789, the output should be 1024. Is there any way of achieving this without using any loops but just using some bitwise operators? I'm a little confused about the following sentences. Could you please tell me which one(s) is/are correct?        The first and the second chapter are difficult.   The first and the second chapters are difficult.   The first and second chapters are difficult.   The first and second chapter are difficult.      I believe #1 &amp; #3 are correct, while #2 &amp; #4 are incorrect.  But when seeing the answers to the Quora question , I wonder why they say #2 is correct. Date(time) ranges using `datetime2` What does the typical workflow of a journal look like? Search for ,        ,                        and you will see that "results found containing __" is just a little too close to the header. It's not like there isn't  to have it be a little lower, closer to "Search":          The UI has been updated since I took the above screenshots, and the text you search for is  (which fixes another design issue but not the one in this question): Given a 4-vector $p^\mu$ the Lorentz group acts on it in the vector representation: $$ \tag{1} p^\mu \longrightarrow (J_V[\Lambda])^\mu_{\,\,\nu} p^\nu\equiv \Lambda^\mu_{\,\,\nu} p^\nu. $$ However, I can always represent a 4-vector $p^\mu$ using left and right handed spinor indices, writing $$ \tag{2} p_{\alpha \dot{\alpha}} \equiv \sigma^\mu_{\alpha \dot{\alpha}} p_\mu.$$ So the question is: in what representation does the Lorentz group act on $p_{\alpha \dot{\alpha}}$?    There are a lot of questions about this and related topics around physics.se, with a lot of excellent answers, so let me clear up more specifically what I am asking for.  I already know that the answer to this question is that the transformation law is  $$ \tag{3} p_{\alpha \dot{\alpha}} \rightarrow (A p A^\dagger)_{\alpha\dot{\alpha}}$$ with $A \in SL(2,\mathbb{C})$ (how is mentioned for example in ). I also understand that $$ \tag{4} \mathfrak{so}(1,3) \cong \mathfrak{sl}(2,\mathbb{C}),$$ (which is explained for example  by Edward Hughes,  by joshphysics,  by Qmechanic).  So what is missing? Not much really. Two things:   How do I obtain (3) and what is the specific form of $A$, i.e. its relation with the vector representation $\Lambda^\mu_{\,\,\nu}$? Defining the following $$ (\tilde p) \equiv p^\mu, \qquad \Lambda \equiv \Lambda^\mu_{\,\,\nu},$$ $$ \sigma \equiv  \sigma_{\alpha \dot \alpha}, \qquad \hat p \equiv p_{\alpha \dot \alpha},$$ we can rewrite (1) and (2) in matrix form as $$ \tag{5} \hat p \equiv \sigma \tilde p \rightarrow \sigma \Lambda \tilde p  = ( \sigma \Lambda \sigma^{-1}) \hat p,$$ however, this disagrees with (3) which I know to be right, so what is wrong with my reasoning? Why does the transformation law (3) has a form $$\tag{6} A \rightarrow U^{-1} A U,$$ while the usual vector transformation (1) has a form $V \rightarrow \Lambda V$? I suspect this comes from a similar reason to that explained  by Prahar, but I would appreciate a confirmation about this. Vectorization operator every rank 2 oriented matroid is realizable In any Pythagorean triplet at least one of them is divisible by $2$, $3$ and $5$. Show that if $x$, $y$, $z$ are integers such that $x^2 + y^2 = z^2$, then at least one of them is divisible by $2$, at least one is divisible by $3$, and at least one is divisible by $5$.  I know that $x,y,z$ are sides of a right-angled triangles. If I start putting values, then I can show, but have no clue about mathematical approach.  How do I solve it mathematically, using modular arithmetic? I have reviewed both related posts on this site:      The issue I am having is that I have implemented the registry change, rescanned my websites, and I am still being told that IIS 6 is allowing SSL 2.0 connections.  Here's the verbage from the scanning site:     Synopsis : The remote service encrypts traffic using a protocol with known weaknesses. Description : The remote service accepts connections encrypted using SSL 2.0, which reportedly suffers from several cryptographic flaws and has been deprecated for several years. An attacker may be able to exploit these issues to conduct man-in-the-middle attacks or decrypt communications between the affected service and clients.   QUESTIONS:   How do I test this myself so I can continue to troubleshoot the issue? Is there a tool out there that I can use to test? Would I need to disable other connection methods? [PCT 1.0 / TLS 1.0]   Thanks Cut strokes from other shapes via pathfinder How do I change the default application for unknown file types? Ever since installing Bless Hex Editor, all unknown files and text files automatically open with Bless instead of gedit. How do I change it back? I don't want to have to manually associate files with gedit, I just want gedit to be the default if there's no other application set up to open the file.  Solution: modify ~/.local/share/applications/mimeapps.list  [Default Applications]  - text/plain=bless.desktop - application/octet-stream=bless.desktop + application/octet-stream=gedit.desktop I asked a question regarding a very specific feature of a program and whether or not it works with a larger program.  Within hours someone had marked it with "This question may already have an answer here of a similar question, but not related to my question.  The question I asked IS NOT ADDRESSED in the referred-to question. It's frustrating to spend half an hour putting together an intelligent and specific question, and then have someone mark it as a duplicate (or possible duplicate), which apparently causes people to skip over my question. I haven't received any more responses since the question was flagged.   Two questions:  (1) How do I get this flagging removed and (2) what's the best way to prevent these "helpful" flaggings in the future? I have seen many questions like:      My question is: what happens if you receive this money (without doing anything or giving your bank account number) but do not do anything scammer wants?  I especially want to know about what happens with the money you got and possible legal consequences.    Is it considered yours because scammer transfered it to you? Do you have to return it? If yes, to whom and in what form? And finally, how is it that scammers are just sending money to random people? Aren't they scared that someone will simply not return it? I understand that this may be stolen money, but it surely took some effort (cash/time) to "acquire" it, so why are they just sending it away?