I'm trying to break down a mathematic expression into pieces and I was trying to use the Regex /\([^)]+\)/ to do the trick (). But reading that answer, I understood that this Regex will be searching for the first closing parenthesis ) to finish, giving me trouble when handling, for instance:   (2*x^2 + 5*x - (2*x - 3)^(1/2))/(1 + x) ^                      ^      ^ START                IGNORE FINISH   Since I'm not really good with coming up with Regex, I'm wondering if I should handle this with strpos, substr and str_replace or is there a different Regex to apply to preg_match_all and get the correct set of parenthesis?   Note: This function will be recursive in order to solve inner parenthesis.  EDIT:   My expected output in this case:   $array = null; $expression = '(2*x^2 + 5*x - (2*x - 3)^(1/2))/(1 + x)'; $expression = str_replace(' ', '', $expression); preg_match_all('MAGIC EXPRESSION HERE', , $array); print_r($array);  // Output array(     [0] =&gt; (2*x^2+5*x-(2*x-3)^(1/2))     [1] =&gt; (1+x) )   Thanks.
Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown number of open/close braces nested within the outer braces?  For example:  public MyMethod() {   if (test)   {     // More { }   }    // More { } } // End   Should match:  {   if (test)   {     // More { }   }    // More { } }
General theorems for consistency and asymptotic normality of maximum likelihood I'm interested in a good reference for results concerning asymptotic properties of maximum likelihood estimators. Consider a model $\{f_n(\cdot \mid \theta): \theta \in \Theta, n \in \mathbb N\}$ where $f_n(\mathbf x \mid \theta)$ is an $n$-dimensional density, and $\hat \theta_n$ is the MLE based on a sample $X_1, \ldots, X_n$ from $f_n(\cdot \mid \theta_0)$ where $\theta_0$ is the "true" value of $\theta$. There are two irregularities I'm interested in.    The data $X_1, \ldots, X_n$ are not iid and, as a result, the Fisher information about $\theta$ accrues at a rate slower than $n$.  $\Theta$ is a bounded set, and with positive probability $\hat \theta_n$ lies on the boundary. The boundary corresponds to a "simpler" model, and so there is particular interest in whether or not $\theta_0$ lies on the boundary.    My particular questions are   Letting $J_n(\theta)$ denote the observed Fisher information corresponding to $\theta$, and suppose $\theta_0$ lies in the interior of $\Theta$. Under what conditions is $$\left[J_n(\hat \theta_n)\right]^{1/2}(\hat \theta_n - \theta_0)$$ asymptotically normal as $n \to \infty$? In particular, are the regularity conditions similar to the usual ones, with the relevant modification being $J_n(\hat \theta_n) \to \infty$ in some sense? Suppose instead that $\theta_0$ is on the boundary, and again recall that $\hat \theta_n = \theta_0$ happens with positive probability - for concreteness, in a mixed effects model $Y_{ij} = \mu + \beta_i + \epsilon_{ij}$ we can have $\hat \sigma_{\beta}^2 = 0$. Under what conditions does $\hat \theta_n \to \theta_0$ (almost surely or in probability) and under what conditions will $\hat \theta_n = \theta_0$ eventually (this probably fails for the mixed effects model, but corresponds to "oracle" properties for the LASSO and related estimators, so perhaps it is too much to ask for general results)?   Again, just a pointer to a text with results at this level of generality would be greatly appreciated. Why $SU(3)$ and not $U(3)$? How would I shift my whole set of equations/calculations at the left, to be aligned with "Example"?        \documentclass[11pt,a4paper]{report} \usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array} \usepackage{parskip}   \theoremstyle{plain} \newtheorem{thm}{Theorem}[chapter] % reset theorem numbering for each chapter \newtheorem{lem}[thm]{Lemma} \newtheorem{prop}[thm]{Proposition} \newtheorem*{cor}{Corollary}  \theoremstyle{definition} \newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers \newtheorem{exmp}[thm]{Example} % same for example numbers \newtheorem{conj}[thm]{Conjecture}  \theoremstyle{remark} \newtheorem*{rem}{Remark} \newtheorem*{note}{Note}   \title{My Thesis Title} \author{My Name} \date{\today} \renewcommand\labelenumi{(\theenumi)} \renewcommand\theenumi{\roman{enumi}} \setlength{\parindent}{1em}  \begin{document}  \chapter{Addition}  \begin{exmp}  Here is an example. \begin{align} \nonumber (a+b)^3 &amp;= (a+b)^2(a+b)\\ \nonumber &amp;=(a^2+2ab+b^2)(a+b)\\ \nonumber &amp;=(a^3+2a^2b+ab^2) + (a^2b+2ab^2+b^3)\\ \nonumber &amp;=a^3+3a^2b+3ab^2+b^3 \nonumber \end{align} \end{exmp} \end{document} Automating DB Restore from network share Change HTML Produced by wp_list_comments() I am developing a WordPress theme for which I would like each comment's timestamp wrapped in in a &lt;span&gt; element for the sake of styling it with CSS rules. However,  as I use it in my theme's comments.php template does not seem to provide options to alter the HTML produced:  &lt;ol class="comment-list"&gt;     &lt;?php         wp_list_comments( array(             'style'       =&gt; 'ol',             'format'      =&gt; 'html5',             'short_ping'  =&gt; true,         ) );     ?&gt; &lt;/ol&gt;   which produces timestamps as such:  &lt;time datetime="2015-12-21T19:09:49+00:00"&gt; december 21st,  2015 on 19:09 &lt;/time&gt;   How can I alter the function's output to include a &lt;span&gt;element around each &lt;time&gt; element without altering core files?  I've tried looking at my theme's functions.php, as well as WordPress wp-includes/comment.php and wp-includes/comment-template.php. None of them deal with the actual tag structure of the comment timestamps generated by wp_list_comments(), so there was nothing there for me to play with. How to create a link to a URL provided in a bib file with custom text Using biblatex, how can I get a URL from the bib file so that I can use it in the \href command?  I am guessing that the \usefield command is what I am looking for and that in order to use that I would need the \entrydata command. But both are undefined.  \documentclass{article} \usepackage[backend=biber]{biblatex} \usepackage{hyperref}  \usepackage{filecontents} \begin{filecontents*}{sources.bib} @online{biblatex,     url = {http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf},     urldate = {2018-02-02}, } \end{filecontents*}  \addbibresource{sources.bib}  \begin{document}      % This would work, but I don't want to duplicate the URL from the bib file:     \href{http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf}{biblatex documentation}      % Does not work because \citeurl{biblatex} is already a link, not the URL:     %The \href{\citeurl{biblatex}}{biblatex documentation}      % Does not work because \usefield and \entrydata are undefined:     %The \entrydata{biblatex}{\usefield\href{url}{biblatex documentation}}      \printbibliography \end{document} How do you handle aspect ratio differences with Unity 2D? I've gotten a lot of answers to this question, but they are all generic and generally not very useful.  None of the tutorials talk about aspect ratio and dealing with mobile devices and there are a zillion ways to do it, all seem to have gotcha's and flaws.  I really would love to know what successful games have used to handle different aspect ratios on iOS and Android without making a zillion different sized assets.  I am strictly speaking mobile, not desktop, specifically with Unity and I don't care about the UI, I only care about the gameplay canvas.  Issues I have in mind is when there are key things that have to be in certain places and cannot fall off the screen.  Using black bars on top or bottom is unacceptable these days. Imagine this directory structure:  app/    __init__.py    sub1/       __init__.py       mod1.py    sub2/       __init__.py       mod2.py   I'm coding mod1, and I need to import something from mod2. How should I do it?    I tried from ..sub2 import mod2 but I'm getting an "Attempted relative import in non-package".  I googled around but found only "sys.path manipulation" hacks. Isn't there a clean way?      Edit: all my __init__.py's are currently empty    Edit2: I'm trying to do this because sub2 contains classes that are shared across sub packages (sub1, subX, etc.).  Edit3: The behaviour I'm looking for is the same as described in  (thanks John B) How can I '\input' a file without getting the implicit newline? Finding the missing digits of $23!$ It is given $23!=2585201xy38884976640000$. Now it is required to find the value of $x$ and $y$. I know I could find it by using divisibility rules and solving simultaneous equations. Is there any other way to solve it (without computing it by a calculator)? This question is just out of curiosity. How to access object attribute given string corresponding to name of that attribute Was or is? Confusion There was a post this morning asking about how many people disable JavaScript. Then I began to wonder what techniques might be used to determine if the user has it disabled.   Does anyone know of some short/simple ways to detect if JavaScript is disabled? My intention is to give a warning that the site is not able to function properly without the browser having JS enabled.   Eventually I would want to redirect them to content that is able to work in the absence of JS, but I need this detection as a placeholder to start. $\displaystyle \int\nolimits_0^8 \sqrt{x^4+4x^2}\,dx$.   Alright, so I thought I had this figured out. Here's what I did:   I factor out an $x^2$ to get $\sqrt{x^2(x^2+4)}$. I let $x = 2\tan(\theta)$, therefore the integrand is $\sqrt{4\tan^2(\theta)  (4\tan^2(\theta) + 4)}$. Factor out a 4 and it becomes $\sqrt{(16\tan^2(\theta)  (\tan^2(\theta) + 1))}$ Which equals $\sqrt{16\tan^2(\theta) \sec^2(\theta)}$ This is easy to take the sqrt of. The integrand becomes $4\tan(\theta)\sec(\theta)$. Now, the integral of this is $4\sec(\theta)$ And it's evaluated from $0$ to $\arctan(4)$ right? Because as $x$ goes to $0$, so does $\theta$, and as $x$ goes to $8$, $\theta$ goes to $\arctan(4)$... But the end result $(4 (\sec(\arctan(4)) - 1) )$ isn't the correct answer   I put it into WolframAlpha and I get $(8/3) (17\sqrt{17} - 1)$, which is the right answer. How did they get that? (there's no "show steps" option)  Any help is greatly appreciated!  PS, what's the syntax for doing sqrts and exponentials? I am tired of always trying to guess, if I should escape special characters like '()[]{}|' etc. when using many implementations of regexps.  It is different with, for example, Python, sed, grep, awk, Perl, rename, Apache, find and so on. Is there any rule set which tells when I should, and when I should not, escape special characters? Does it depend on the regexp type, like PCRE, POSIX or extended regexps? Object Positions Reset On Blender Load So I am attempting to make a modular environment in Blender, so I'm modeling many pieces in one scene to make sure they all match up properly before separating them out.  However, whenever I restart Blender after saving and closing it, many of my grouped objects (and their subobjects) have positions reset NOT to where I placed them.  For example, take a look at this:   Here you can see that the door pieces are in the "open" state, when I left them closed AND the "column" for the wall on the left has been moved from being flush with the wall (on the side) to being inside it.  It appears to be trying to move all of the objects to 0,0,0 which is what is messing this up. I'm not sure if it's an object hierarchy problem, but here is my hierarchy if anyone has ideas there:  Wall_Normal (parent)   Wall_Normal_Column (child)   Empty Axis Object (parent)   Door_Left (child a) Door_Right (child b)   Is there a reason why object positions (and their relative subobjects) aren't being saved? Force alt + tab to switch only on current workspace in GNOME shell How to check for an active Internet connection on iOS or macOS? How to type latin small letter c with cedilla I run Ubuntu on a DELL XPS 13 notebook that has an US keyboard configured as US international. After upgrading to version 13.10 I can no loger get a cedilla by typing '+C. Instead, I get a "ć".  What should I do to get a "ç"?  I am using Ubuntu Gnome 13.10 64 bit. Convert list of ints to one number?