I need a regular expression that matches words regardless of order. As an example, these lines should match with the marked range, A longword1 B longword2 C   ^-------------------^  A longword2 B longword1 C   ^-------------------^  while these shouldn't: A longword1 B longword1 C A longword2 B longword2 C A longword1 B A longword2 C  (A, B, C are fillers, they can be essentially any text) It is possible to just use alternations, such as: \b((longword1).*?(longword2)|(longword2).*?(longword2))\b. But the regex would grow factorially, i.e. three words would need 3! alternates. It's also possible to use subroutines, e.g. \b((?'A'longword1).*?(?'B'longword2')|(?P&gt;B).*?(?P&gt;A))\b. Although shorter, I would still need to include all of its permutations. Now I've read  and , but the accepted answers don't exactly solve my problem. Using \b(?=.*longword1)(?=.*longword2).*\b would match the whole line instead of the range I've shown. I understand, that it would be much easier if I checked the sentence against a list of words. But my current use case prevents it from being possible; I can only use regexes. Here are some links to demonstrate what I meant: EXPECTED:  Using alternates:  Using subroutines:   INCORRECT:  Using positive lookahead (as linked):   Are there any simpler regex(es) to tackle this?
Obviously, you can use the | (pipe?) to represent OR, but is there a way to represent AND as well?  Specifically, I'd like to match paragraphs of text that contain ALL of a certain phrase, but in no particular order.
How to fix "sudo: unable to open ... Read-only file system"? The title might not be as descriptive as I would like it to be but couldn't come up with a better one.  My server's file system went into Read-only. And I don't understand why it does so and how to solve it.  I can SSH into the server and when trying to start apache2 for example I get the following :  username@srv1:~$ sudo service apache2 start [sudo] password for username: sudo: unable to open /var/lib/sudo/username/1: Read-only file system  * Starting web server apache2                                                                                                                                                                                                               (30)Read-only file system: apache2: could not open error log file /var/log/apache2/error.log. Unable to open logs Action 'start' failed. The Apache error log may have more information.   When I try restarting the server I get :  username@srv1:~$ sudo shutdown -r now [sudo] password for username: sudo: unable to open /var/lib/sudo/username/1: Read-only file system   Once I restart it manually it just start up without any warning or message saying something is wrong.  I hope somebody could point me into the right direction to resolve this issue. I need to build a list of files present in a directory but also pass in a file containing a list of directories to exclude.  I've seen the below suggestion but I've had no luck with it when it comes to the type flag:  find $dir_name $(printf "! -name %s " $(cat $exclude_file))   Is there a way I can do it or will I need to create the entire list and then work through it removing ones that partially match ones in the exclude directory. Thermodynamics of supercooled water Now that it's been freezing outside for the last few days, I experimented a bit with supercooling. I've left a bottle of clean water outside for a few hours, and behold, when I shook the bottle, the liquid began to freeze rapidly, as expected.   However, not all of the water froze, only about half of it. This got me thinking.  I reasoned that happens because freezing releases heat, and that heat raises the temperature of the ice and remaning water to 0$^\circ$C, at which point the freezing stops.  To try to quantify this, set   $H_f = 334000 \frac{J}{kg}$, the "freezing heat" (enthalpy of fusion) of ice, $c_i = 2110 \frac{J}{kg\cdot K}$, specific heat of ice, $c_w = 4181 \frac{J}{kg\cdot K}$, specific heat of water, $M$, initial mass of supercooled water, $T_0$, initial temperature of supercooled water, $m$, mass of ice at a given moment, $T$, temperature at a given moment.   We suppose that the energy released by the freezing of a $\textrm dm$ mass of ice is used up by raising the temperature of both the already frozen ice ($m$) and the remaining water ($M-m$):  $$ \textrm dm \cdot H_f = c_i m \cdot\textrm dT + (M-m)c_w \cdot\textrm dT$$  By rearranging we get a linear differential equation for $m(T)$:  $$\frac{\textrm dm}{\textrm dT}+\frac{c_w-c_i}{H_f}m = \frac{c_w}{H_f}M$$  The solution of this equation, using the initial condition that at $T=T_0$, $m=0$:  $$ m = M \frac{c_w}{c_w-c_i}\left[ 1-e^{-\frac{c_w-c_i}{H_f}(T-T_0)} \right]$$  This looks neat, however, plugging in the actual values of the constants, $T = 0^\circ$C and $T_0 = -6^\circ$C, I get that little more than 7% of the water should freeze - as opposed to more than half, as I've observed. What's worse, the formula can be used to calculate the starting temperature required to freeze all the supercooled water: $$T_{all} = \frac{H_f \log\frac{c_w}{c_i}}{c_i-c_w}=-110.26^\circ \textrm C$$ which seems absurd.  Where is the error in the calculation above?  I've made a number of assumptions which may or may not hold:   the constants are really constant. I think this is a good approximation for $c_w$, a not that good but still acceptable approximation for $c_i$, and I suppose it holds to $H_f$ to some extent as well. there is no heat transfer with the environment, i.e. the bottle is a closed system. The process seemed fast enough (a few seconds at most) for this to be a good approximation. the system is in a thermal equilibrium at all times and the heat released by the freezing of the ice is distributed evenly in the emerging ice-water mixture. Now this is where I have doubts. Precisely because of the process happening so fast, this might not be true at all. However, acknowledging the presence of temperature variations makes the problem order of magnitudes harder: one has to solve a system of partial differential equations that take heat transfer, the shape of the bottle and \$deity knows what else into account. Can an inanimate thing lift Mjolnir? Can an inanimate thing can lift Mjolnir without the help of a living being (unworthy)  Scenario 1  Mjolnir in a very light car with a sail attached to it, then a very strong wind blew and moved the car uphill.  It is possible or not?  Scenario 2  Can upward wind alone lift the Mjolnir? This is a tricky one and I've always relied on techniques, such as permission-based emails (i.e. only sending to people you have permission to send to) and not using blatantly spamish terminology.  Of late, some of the emails I send out programmatically have started being shuffled into people's spam folder automatically and I'm wondering what I can do about it.  This is despite the fact that these particular emails are not ones that humans would mark as spam, specifically, they are emails that contain license keys that people have paid good money for, so I don't think they're going to consider them spam  I figure this is a big topic in which I am essentially an ignorant simpleton. Trigonometry and algebra question Given:   The total length of ad + dc The lengths of each ab, bc and ca That angle adb = angle cdb   How can I work out lengths ad and cd A group is generated by two elements of order $2$ is infinite and non-abelian Battery mAh meaning What exactly does mAh rating means? I know that it means the milliamperes supplied by the battery in one hour but i need a more conceptual and practical definition/example.   How does mAh rating tell the current supplied to the load? How does it vary with the load specification.   Also, suppose a mobile phone's battery has 3000mAh, if i supply it with 1000mA, then does it mean that the battery will be fully charged in 3 hours?   And will a 3000 mAh battery deliver a current of 3000mA for 1 hour to a load? Will this rating degrade in a practical scenario. Please explain. How many solutions are there to $x_1 + x_2 + ... + x_5 = 21$? How many solutions are there to the equation      $x_1 + x_2 + x_3 + x_4 + x_5 = 21$    where $x_1, i = 1,2,3,4,5$ is a nonnegative integer such that $0 ≤ x_1 ≤ 3, 1 ≤ x_2 &lt; 4$, and $x_3 ≥ 15$?  I have correctly completed the previous parts of the question but am having trouble with this particular restriction.  The total number of solutions to the equation is $C(25,21) = 12650$.  I have tried to do each restriction individually:  For $0 ≤ x_1 ≤ 3$, I solved this by subtracting the number of solutions when $x_1 ≥ 4$ from the total number of solutions. This is $C(25,21) - C(21,17) = 5985$.  For $1 ≤ x_2 &lt; 4$, I have $C(24,20) - C(21,17) = 5985$.  For $x_3 ≥ 15$, I have $C(10,6) = 210$.  However, the restriction is when these are all together. I am not sure how to proceed. The answer is $106$. I'm using the built in Screen Sharing tool in El Capitan to control an iMac from a Macbook Pro in full screen mode. Everything works beautifully except that many special keys and gestures are intercepted by the local Mac and not sent to the shared Mac. Specifically:   Ctrl-Arrow (Desktops and Mission Control) F3 (Mission Control) F4 (LaunchPad) Three finger swipe (Switch between Desktops, Mission Control, Exposé) Two finger swipe from left side (Notification Center) Pinch with four fingers (Launchpad)   I can't find any way to switch between desktops on the remote machine other than manually opening the Mission Control app from the Finder or Dock. Disabling the gestures on the local machine doesn't help; they still don't get sent to the remote machine.  Is there any way to get special keys and gestures passed to the shared machine? How can I find the program I'm hiding in bash How to create a sub array from another array in Java? Calculate the Factor Group $(\mathbb{Z}_4 \times \mathbb{Z}_6)/\langle(0,2)\rangle$ Windows 7 stuck on CLASSPNP.SYS I'm running Win 7 x86 on a Lenovo Thinkpad Z61m in dual boot mode with Win XP, both OSes are running on separate partitions. I have a faulty battery and if left unplugged my laptop shuts usually down within 10 minutes. Last night, it shut down due to this, but after plugging in AC power and starting back up I'm stuck at the "Starting Windows" screen, I'm unable to boot into safe mode or into recovery mode(XP boots fine).  I believe I had installed some Win 7 updates the same/previous day. From one of the boot options I was able to see that Windows 7 is getting stuck on CLASSPNP.SYS  How can I go about fixing this?  I do have a complete Win 7 Restore CD that I created after setting up my machine, I'm unable to boot into this either.  Please help! Does an unbalanced sample matter when doing logistic regression? Asymptotics of uniformly continuous functions over $\mathbb R$ Suppose $R\neq 0$ is a commutative ring with $1$. Let $M$ be a free $R$-module. I would like to prove that $M$ is a flat $R$-module. Everywhere I have looked (mostly online) this is proved by first proving that every free module is projective, and then proving that every projective module is flat. Unfortunately, Atiyah &amp; Macdonald's "Introduction to Commutative Algebra" (Chapter 2) does not discuss projective modules. But the result that every free module is flat comes very handy in the exercises.   So my question is,     Is it possible to prove that every free module is flat just by   definitions and without appealing to projective modules?   Thanks! Difference between the i386 download and the amd64? What is the difference between standard i386 download and the amd64 download of Ubuntu 11.04? I am currently running the i386 on an amd machine, would my system work better with the amd64 download instead? (my machine was running Windows 7 64bit, but I neglected to look at that prior to installing Ubuntu). How can I define a mathematical function as a LaTeX macro? Why I can't read a read only file?