EDIT: As already explained in the original question, re.escape() is not a solution for this use case. This is therefore not a duplicate of . Please read the question before closing as a duplicate!  Java allows the use of \Q and \E to escape blocks of characters, instead of only escaping characters one at a time. .  Is there an equivalent for this in Python? I've reviewed the  and couldn't find it, but I want to make sure I'm not missing something.  I know there's re.escape() which will automatically escape all non-ASCII characters, but this doesn't work for my use case.  My use case is effectively taking a user-supplied string of format foo&lt;a&gt;bar&lt;b&gt;baz&lt;c&gt; and turning it into a regex that will match foo followed by a number then bar then another number then baz then another number. It would then capture the values of &lt;a&gt;, &lt;b&gt;, and &lt;c&gt;. Also, it's possible that foo, bar and baz could instead be strings containing regex special characters, such as in the case of $.cities[&lt;a&gt;].name.  Java code is something like this:  String key = "foo&lt;a&gt;bar&lt;b&gt;baz&lt;c&gt;";  String keyRegex = "^\\Q" + key + "\\E$"; Matcher m = Pattern.compile("&lt;.*?&gt;").matcher(key);  while (m.find()) {     keyRegex = keyRegex.replace(m.group(), "\\E([0-9]+)\\Q"); }  keyPattern = Pattern.compile(keyRegex);
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 ?
Usually \label does not create any white spaces. However, It creates an white space when \label is used after \phantomsubcaption from subcaption package.   Why? How can I get rid of this white space?   Here is a MWE:  \documentclass{article} \usepackage{subcaption}  \begin{document}  \section{a} a\label{sec:a}b% no white space between `a' and `b'  \begin{figure}   \centering   {a\phantomsubcaption\label{fig:a}}%   {b\phantomsubcaption\label{fig:b}}   \caption{With label}% undesired white space between `a' and `b' \end{figure}  \begin{figure}   \centering   {a\phantomsubcaption}%   {b\phantomsubcaption}   \caption{Without label}% no white space between `a' and `b' \end{figure}  \end{document} I have a problem with the endfloat package and unicode characters.  When I compile the following, everything works as expected:  \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx}  \begin{document}  \begin{figure} \caption{Ö} \end{figure}  \end{document}   However, when I also load the endfloat package (\usepackage{endfloat}), I get the following error message:  ! Package inputenc Error: Unicode char \u8:ÖÖ not set up for use with LaTeX.   This could be a bug, but my suspicion is that I'm making a mistake somewhere.  I'm hardly the first person to use special characters with the endfloat package.  However, the above example is so simple, I don't see where I could have made a mistake.  Any advice is appreciated.  Edit: The file is of course encoded using utf-8. Facebook changed how their API serves profile pictures that are requested with a non-application scope UID. Now because before Graph API 2 all applications shared the original UID, if users like me has joined Stack Exchange websites before  2, rolling out their profile pictures are not shown properly. Facebook suggests to use an access token to query those profile pictures, either an application access token or a user access token. A user access token is not a reliable option at all, because it would only work for users who joined website with Facebook and are currently logged in. Application access tokens, by the way, can be used by creating sort of a proxy that would retrieve a profile picture from Facebook and display it. Yet still it's not perfect. I think the best solution is to communicate with Facebook and ask them to offer an opportunity to convert old Graph API 1 UID's to application scope user IDs. I have a question about editing practices:  Does it look good to edit a question you have just answered?  For example: say I had just answered a question, then saw that the question had some minor formatting issues. Should I edit it? Does it turn up voters off when they see that I am answering a question I changed, possibly to better suit my answer? SD card partitioning? why? how? According to , $[0,1]$ cannot be written as union of countable disjoint closed sets, is the same true about (uncountable) family of disjoint closed intervals ? How do I make a bootable USB OS X installer on a Mac? Does anyone have a Terminal command-line recipe for making a new bootable USB flash drive for one of the new MacBook Air's?  Is there a way to dd copy the USB boot device that comes in the box and make the new copy bootable?  I'd like to make a new backup copy of the USB rescue device for my MBA, preferably on a much larger flash drive with room for a backup of some of my working directories.  Added:  And is it possible to make, not just a rescue drive, but a bootable USB drive that will boot a fully updated version of the OS (say 10.6.8 or later)?  If so how on a MacBook Air 11, and how big a USB stick will this require? The trigonometric ratios of an angle greater than $90^\circ$ are equal to the supplementary angle's ratios.  I'm just clarifying this, but the ratios don't actually exist for angles greater than $90^\circ$ right? (since by definition these ratios are of a right angle triangle). Is it just mathematical custom to assume the ratios of an angle greater than $90^\circ$ to be equivalent to its supplementary angle's ratios? For convenience? Open more than one instance of Windows 10 settings How can I open more than one instance of the Windows settings?  It wasn't a problem with the old style, but with the new one I can't seem to open multiple settings simultaneously and side by side.  Example of the new settings window: I would like to have my whole document showing a blank line (or space) between paragraphs and no indentation. I know how to do it line by line, but is there a way to change that with just one or a few lines at the beginning of the document? Like a package you can install, or a new command? My system freezes completely at random, frequent intervals. I started to have the same problem in Ubuntu 14.04 but after recent upgrade to 16.04 there is no improvement, in fact it seems worse.  When it happens, it's impossible to do anything. I've tried everything in this thread:  but nothing works, I have to hard reset. I have read all the system logs and journalctl but there is never any information that could help diagnose the problem.  This is a dual-boot system with Windows 10 and there's no problem there, so it's not defective hardware.  My laptop has an Intel Bay Trail processor (Pentium N3540) What are the differences between Generics in C# and Java... and Templates in C++? Parameter evaluation order before a function calling in C Can it be assumed a evaluation order of the function parameters when calling it in C ? According to the following program, it seems that there is not a particular order when I executed it.   #include &lt;stdio.h&gt;  int main() {    int a[] = {1, 2, 3};    int * pa;      pa = &amp;a[0];    printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa), *(pa++),*(++pa));    /* Result: a[0] = 3  a[1] = 2    a[2] = 2 */     pa = &amp;a[0];    printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa++),*(pa),*(++pa));    /* Result: a[0] = 2  a[1] = 2     a[2] = 2 */     pa = &amp;a[0];    printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa++),*(++pa), *(pa));    /* a[0] = 2  a[1] = 2 a[2] = 1 */  } How do I completely remove an image from my .blend file? I'm currently working on the following question:  "At least one of Plato and Democritus believed in the theory of forms. Plato believed in the theory of forms only if he was not an atomist, and Democritus was an atomist only if he did not believe in the theory of forms. Democritus was an atomist. Prove, using Natural Deduction, that Plato was not an atomist"  I have been working for quite some time to take the information and turn it into a set of literals and statements I can work with.  So far, I have got $P \lor D$,  $P \Rightarrow \lnot a$,  $D \Rightarrow A$,  $D = A$  However, I cannot seem to make these prove the statement using natural deduction, any hints? Let $R$ be a commutative ring with 1 then why does $a\in N(R) \Rightarrow 1+a\in U(R)$? Let $R$ be a commutative ring with 1, we define  $$N(R):=\{ a\in R \mid  \exists k\in \mathbb{N}:a^k=0\}$$  and  $$U(R):=\{ a\in R \mid a\mbox{ is invertible} \}.$$  Could anyone help me prove that if $a\in N(R) \Rightarrow 1+a\in U(R)$?  I've been trying to construst a $b$ such that $ab=1$ rather than doing it by contradiction, as I don't see how you could go about doing that. Geometric proof that a Pythagorean triple has a number divisible by $3$? Can I infer from “If $a,b \in \mathbb{N}$ such that $(a,3)=(b,3)=1$ then $a^2+b^2\neq c^2$ for any $c\in\mathbb{N}$” that any pythagorean triple has a number which is divisible by $3$? If so, how can this relationship be proved geometrically? How come unpolarized light does not undergo destructive interference? List all commands that a shell knows What can I type at my shell (which happens to be bash) that will list all the commands that are recognized?  Also, does this differ by shell? Or do all shells just have a "directory" of commands they recognize?  Secondly, different question, but how can I override any of those? In other words how can I write my own view command to replace the one existing on my Ubuntu system, which appears to just load vim. How do I enable the "Universe" repository?