I am attempting to remove the &lt;span class="notranslate"&gt;&lt;/span&gt; of a string using a regex. Basically it's because Google Translate API needs that kind of wrapping if some string should not be translated, which is what I need.  I have that regex to do this (it needs to handle new lines, that's why [\S\s] is used instead of .) :  &lt;span class="notranslate"&gt;[\S\s]+(?=&lt;\/span&gt;)&lt;\/span&gt;   However when testing it, it is way too greedy because for that input for example:  &lt;span class="notranslate"&gt;%1&lt;/span&gt; per il seguente motivo: &lt;span class="notranslate"&gt;\n&lt;/span&gt; &lt;span class="notranslate"&gt;%2!d!&lt;/span&gt;   That regex gets the whole string. I was a little confused because many answers (including "") seems to indicate that ? as a non greedy thing.  I need to have it find every span wrap with the notranslate class, not all of them if there are many.
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
How do I make my glasses look realistic? Primary key or Unique index? At work we have a big database with unique indexes instead of primary keys and all works fine.  I'm designing new database for a new project and I have a dilemma:  In DB theory, primary key is fundamental element, that's OK, but in REAL projects what are advantages and disadvantages of both?  What do you use in projects?  EDIT: ...and what about primary keys and replication on MS SQL server? Hyperlinks are not visible in the generated PDF CV I need to knock out a quick animation in C#/Windows Forms for a Halloween display.  Just some 2D shapes moving about on a solid background.  Since this is just a quick one-off project I really don't want to install and learn an entire new set of tools for this.  (DirectX dev kits, Silverlight, Flash, etc..)  I also have to install this on multiple computers so anything beyond the basic .Net framework (2.0) would be a pain in the arse.  For tools I've got VS2k8, 25 years of development experience, a wheelbarrow, holocaust cloak, and about 2 days to knock this out.  I haven't done animation since using assembler on my Atari 130XE (hooray for page flipping and player/missile graphics!)  Advice?  Here's some of the things I'd like to know:   I can draw on any empty widget (like a panel) by fiddling with it's OnPaint handler, right?  That's how I'd draw a custom widget.  Is there a better technique than this? Is there a page-flipping technique for this kind of thing in Windows Forms?  I'm not looking for a high frame rate, just as little flicker/drawing as necessary.   Thanks.  Post Mortem Edit ... "a couple of coding days later"  Well, the project is done.  The links below came in handy although a couple of them were 404.  (I wish SO would allow more than one reply to be marked "correct").  The biggest problem I had to overcome was flickering, and a persistent bug when I tried to draw on the form directly.   Using the OnPaint event for the Form: bad idea.  I never got that to work; lots of mysterious errors (stack overflows, or ArgumentNullExceptions).  I wound up using a panel sized to fill the form and that worked fine. Using the OnPaint method is slow anyway.  Somewhere online I read that building the PaintEventArgs was slow, and they weren't kidding.  Lots of flickering went away when I abandoned this.  Skip the OnPaint/Invalidate() and just paint it yourself.  Setting all of the "double buffering" options on the form still left some flicker that had to be fixed.  (And I found conflicting docs that said "set them on the control" and "set them on the form".  Well controls don't have a .SetStyle() method.)  I haven't tested without them, so they might be doing something (this is the form):      this.SetStyle(ControlStyles.UserPaint, true);     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);    So the workhorse of the code wound up looking like (pf is the panel control):      void PaintPlayField()     {         Bitmap bufl = new Bitmap(pf.Width, pf.Height);         using (Graphics g = Graphics.FromImage(bufl))         {             g.FillRectangle(Brushes.Black, new Rectangle(0, 0, pf.Width, pf.Height));             DrawItems(g);             DrawMoreItems(g);             pf.CreateGraphics().DrawImageUnscaled(bufl, 0, 0);         }     }   And I just called PaintPlayField from the inside of my Timer loop.  No flicker at all. I needed to create a list of lists in Python, so I typed the following: my_list = [[1] * 4] * 3  The list looked like this: [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]    Then I changed one of the innermost values: my_list[0][0] = 5  Now my list looks like this: [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]]    which is not what I wanted or expected. Can someone please explain what's going on, and how to get around it? Does the order in which I set properties using the object initializer syntax get executed in the exact same order?  For instance if I do this:  var s = new Person { FirstName = "Micah",                      LastName = "Martin",                      IsLoaded = true                    }   will each property get set in the same order? Is there a way to resolve probability of an event, given another event that never happens? Mathematically speaking the problem is:  Given that $P(B) = 0$,  $$P(A|B)=\frac{P(A \cap B)}{P(B)} = \frac{0}{0}$$  Is this probability vacuously $0$ of $1$? Can we show that it's one or the other? Why can't the Polynomial Ring be a Field? I'm currently studying Polynomial Rings, but I can't figure out why they are Rings, not Fields. In the definition of a Field, a Set builds a Commutative Group with Addition and Multiplication. This implies an inverse multiple for every Element in the Set.   The book doesn't elaborate on this, however. I don't understand why a Polynomial Ring couldn't have an inverse multiplicative for every element (at least in the Whole numbers, and it's already given that it has a neutral element). Could somebody please explain why this can't be so? If I have two variables:  Object obj; String methodName = "getName";   Without knowing the class of obj, how can I call the method identified by methodName on it?  The method being called has no parameters, and a String return value. It's a getter for a Java bean. I currently only have remote access to this CentOS box, I need to move /var form the primary RAID to a new set of disks that was installed with more space, My current thoughts on how to accomplish this is to temporarily mount the new RAID to /tmp/var. rsync everything from /var to /temp/var then modify the fstab to point /var at the new disks.  Here is my question. how do I delete the existing /var on the primary disks once I have the new disks mounted to that location (assuming this is even possible remotely)? When I create a form using the form API, the resulting html includes all sorts of unwanted divs. For example, if I use:  $form = array(     'myFieldset' =&gt; array(         '#type' =&gt; 'fieldset'     ) );   The resulting html looks like this:   &lt;form action="/drupal-7.15/?q=chercheur" method="post" id="form-chercheur" accept-charset="UTF-8"&gt;     &lt;div&gt;         &lt;fieldset class="form-wrapper" id="edit-myfieldset"&gt;             &lt;div class="fieldset-wrapper"&gt;             &lt;/div&gt;         &lt;/fieldset&gt;         &lt;input type="hidden" name="form_build_id" value="form-87Dv5ezVpaLI5mD345ofMkLgPhsv_dawudUp73ePQTc" /&gt;         &lt;input type="hidden" name="form_token" value="sXXINWr7rmParm0tRJoEb6QKGIH_QH-ffRSOtnvxYY0" /&gt;         &lt;input type="hidden" name="form_id" value="form_Chercheur" /&gt;     &lt;/div&gt; &lt;/form&gt;   As you can see, two extraneous divs are added here. They are making the javascript I'm writing uselessly complicated, so I was wondering if there was a way to remove the extraneous divs. Ideally, I would like to obtain something like this:  &lt;form action="/drupal-7.15/?q=chercheur" method="post" id="form-chercheur" accept-charset="UTF-8"&gt;     &lt;fieldset class="form-wrapper" id="edit-myfieldset"&gt;     &lt;/fieldset&gt;     &lt;input type="hidden" name="form_build_id" value="form-87Dv5ezVpaLI5mD345ofMkLgPhsv_dawudUp73ePQTc" /&gt;     &lt;input type="hidden" name="form_token" value="sXXINWr7rmParm0tRJoEb6QKGIH_QH-ffRSOtnvxYY0" /&gt;     &lt;input type="hidden" name="form_id" value="form_Chercheur" /&gt; &lt;/form&gt;   Is this possible? Cast Double to Integer in Java I need to calculate the Cramer Rao lower bound of variance for the parameter $\theta$ of the distribution $$f(x)=\frac{1}{\pi(1+(x-\theta)^2)}$$   How do I proceed I have calculated $$4 E\frac{(X-\theta)^2}{1+X^2+\theta^2-2X\theta}$$  Can somebody help What's the best way to build a string of delimited items in Java? While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be in advance. The best I could come up with off the top of my head was something like this:  public String appendWithDelimiter( String original, String addition, String delimiter ) {     if ( original.equals( "" ) ) {         return addition;     } else {         return original + delimiter + addition;     } }  String parameterString = ""; if ( condition ) parameterString = appendWithDelimiter( parameterString, "elementName", "," ); if ( anotherCondition ) parameterString = appendWithDelimiter( parameterString, "anotherElementName", "," );   I realize this isn't particularly efficient, since there are strings being created all over the place, but I was going for clarity more than optimization.  In Ruby, I can do something like this instead, which feels much more elegant:  parameterArray = []; parameterArray &lt;&lt; "elementName" if condition; parameterArray &lt;&lt; "anotherElementName" if anotherCondition; parameterString = parameterArray.join(",");   But since Java lacks a join command, I couldn't figure out anything equivalent.  So, what's the best way to do this in Java? Execute command from file in current shell I want to executed command from file (which is script) in current shell in terminal.  Example: I have file ch_dir contains following:  #!/bin/bash cd /usr   Now if I execute file usually as following then it executes commands in different shell:  pandya@pandya-desktop:~$ ./ch_dir pandya@pandya-desktop:~$   Here cd /user is executed in different shell.  But I want to execute in Current shell. How do I do that?  Note: Here cd is only used to explain. Question's aim is to execute any command in current shell How to get Scilab 6.0.1 working on Ubuntu 18.04 LTS? I have installed clean Ubuntu MATE 18.04 LTS and installed Scilab from repository here with    sudo apt-get update sudo apt-get install scilab   After installation I tried to launch it from GUI (Applications → Other → Scilab) - it does not start. Then I tried to launch it from terminal with scilab command. Terminal output is as follows:  $ scilab /usr/bin/scilab-bin: error while loading shared libraries: libjava.so: cannot open shared object file: No such file or directory   so it can't find Java. I reported  about this problem.  I checked existence of libjava.so:  $ dpkg -S libjava.so   openjdk-11-jre-headless:amd64: /usr/lib/jvm/java-11-openjdk-amd64/lib/libjava.so   so it is in place.  What should I do to get Scilab 6.0.1 working on Ubuntu 18.04 LTS? How to show that $f$ is differentiable at $x=0.$ Where are some good places to find royalty free stock images? I'm always on the hunt for free stock images to use while I design, what are some good resources for images that are under a a royalty free or creative commons licence? Can toddlers be taught to safely navigate stairs? Why is glass transparent? Once I asked this question from my teacher and he replied "Because it passes light.". "And why does it pass light?" I asked and he said, "Because it is transparent.".  The same question again, Why glass is transparent? Why does light pass through it, while for opaque objects, it does not?