import re  content = "This is a [story] to be told" tag = r'[story]'  print(re.compile(rf'{tag}').search(content))   this returns: &lt;re.Match object; span=(3, 4), match='s'&gt;  I am using the 'r' prefix in the variable and the 'rf' prefix in the regex. Where am I going wrong? It keeps interpreting my variable as a coded string.  In my actual scenario I have a list of tags: [r'[TAG1]', r'[TAG2]', r'[TAG3]'] which I want to iterate over. I have solved the problem by escaping with '\' in every tag's string assignment but this makes the tags unusable when referencing them later, as 1 of the '\'s is not in the beginning or end of string (since strings are immutable).   I could try using slices but that seems incredibly inefficient. Is there a regex solution?
I want to use input from a user as a regex pattern for a search over some text.  It works, but how I can handle cases where user puts characters that have meaning in regex? For example, the user wants to search for Word (s): regex engine will take the (s) as a group.  I want it to treat it like a string &quot;(s)&quot; .  I can run replace on user input and replace the ( with \( and the ) with \) but the problem is I will need to do replace for every possible regex symbol. Do you know some better way ?
Where can I find a Java to C# converter? I needed to convert a Java 1.5se app to C# 2.0.  Does anyone know of a tool (preferably free/open source) to do this? How to tell how many CPUs (cores) you have on Windows 7 Where does tidal energy come from? Kind of an odd, random question that popped into my head. Tidal energy - earth's ocean movement, volcanism on some of Jupiter's moons, etc. - obviously comes from the gravitational interaction between large bodies. On earth the interactions with the moon are pulling water around the surface, creating some amount of heat due to friction, etc.   My question is, where does that energy come from exactly? More specifically, what potential energy source is getting depleted to do that work? Is the earth minutely slowing down in its spin - or are the orbits of earth and the moon subtly altered over time by the counteractive movement and friction of liquids and gasses? Is there a one-liner that allows me to create a directory and move into it at the same time? I find myself repeating a lot of:  mkdir longtitleproject cd longtitleproject   Is there a way of doing it in one line without repeating the directory name? I'm on bash here. Prove $f $ is identically zero if $f(0)=0$ and $|f'(x)|\le|f(x)|$ Stripped out bottom bracket How do I make a bootable Ubuntu USB? Prove that the unit circle, $S^1:=\{(x,y)\in \mathbb{R}^2: x^2+y^2=1\}$, Is a one-dimensional manifold How can I generate and print a 32 bit sequence of 0s and 1s in Qiskit or IBM Q experience quantum lab using quantum random number generator implementation? Re-entering the US for the third time in a year with total of 240 Days I went to the US for 90 days on an ESTA in August to November. Then back to my home country for 1 month and then back again mid December until mid February and now I am going back again after 10 days for another 90 days. Now I can see that some people refer to 180 day rule in a year. My stay will be 240 days in one year with short gaps between coming back. Is the 180 day rule accurate? Some people write that you can do unlimited trips to The US as long as you don't stay more than 90 days. Is that correct? My reason for going there the first time was to visit and travel with an American friend.  After my first visit (she is my girlfriend) moved with me to my home country but has ended up in a custody battle in the US so she needed to return urgently so I returned only to be with her and support her, not to be a tourist.  Then after my second visit I needed to go back to my sick Dad and to rent out my apartment since we left in a rush to go back to the US.  Now, my third visit is to continue to be with my girlfriend and support her in her difficult situation.   My question is, if I do end up in trouble should I tell them this whole story? Or should I just say I am visiting a friend for a third time because I want to see more of the country and I have some more time off before I go back to my job.  I have proof of money in my bank account and I stay and eat with her for free Documented proof that I have a job to return to in my home country My return ticket printed and an address to stay at in the US and I have proof I have an apartment in my home country Code blocks are not prettified on mobile site On Chrome on Android, code blocks on the mobile site have no syntax highlighting, are not a monospaced font, and words are wrapped.  Mobile site on mobile browser:    Desktop site on mobile browser:    Inline code has the same issue, it isn't a monospaced font.  It has been this way for as long as I can remember. Wouldn't be surprised if this is a dupe. runtime error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver "They are quite full up this year." How do you find all subclasses of a given class in Java? How does one go about and try to find all subclasses of a given class (or all implementors of a given interface) in Java? As of now, I have a method to do this, but I find it quite inefficient (to say the least). The method is:    Get a list of all class names that exist on the class path Load each class and test to see if it is a subclass or implementor of the desired class or interface   In Eclipse, there is a nice feature called the Type Hierarchy that manages to show this quite efficiently. How does one go about and do it programmatically? Check Constraint with Case Statement I want to add a check constraint on a column if entered value for column is greater than 3 than it should be saved as 1 else entered value. For that scenario I am using below query but on insertion of data it shows an error message.  create table tblTestCheckConstraint  ( id int, NewColumn int )   alter table tblTestCheckConstraint add constraint chk_tblTestCheckConstraint_NewColumn1 CHECK   (     CASE         WHEN NewColumn &gt;4 THEN 1         ELSE NewColumn     END = 1 )   Insert Statement:   insert into tblTestCheckConstraint values ( 1,5) insert into tblTestCheckConstraint values ( 1,2)   Error Message:   Msg 547, Level 16, State 0, Line 1 The INSERT statement conflicted with the CHECK constraint "chk_tblTestCheckConstraint_NewColumn1". The conflict occurred in database "DBName" , table "dbo.tblTestCheckConstraint", column 'NewColumn'. The statement has been terminated. Somebody asked me this question in a job interview and I replied that their joint distribution is always Gaussian. I thought that I can always write a bivariate Gaussian with their means and variance and covariances. I am wondering if there can be a case for which the joint probability of two Gaussians is not Gaussian? How to get GUI sudo password prompt without command line? Currently, for all my commands that require root access, I have to type them out on a command line.  I would like for the GUI to prompt me to key in my password, when sudo is required, instead of having to type out the commands from command line.  Is there any way to enable this? Previously one version of Ubuntu desktop had this feature out of the box.  This version of Ubuntu (that I am now running) I upgraded from a server installation.  I will add, my user account is already added to sudo group. Thus I can run commands such as sudo gedit or sudo apt-get but I'm not able to install software in the Ubuntu Software Center. English proverb for when a solution comes too late In Flemish we have a saying "Vijgen na pasen". Translated: "figs after Easter". It means a solution comes too late to be of any use.  What is the English equivalent for this?  Some googling gives me "Closing the barn door when the cow has bolted", but the explanation seems to point more towards the wrong solution for a problem. . If you filter out a range of wavelengths, how can you calculate the energy from the remaining wavelengths?   To make it concrete, say we filter everything below 450nm or alternatively above 700nm. Recovering from forgotten lock pattern My son has an impression tablet 10 and has forgot the lock pattern. How can we reset it without knowing the code?