I'm a still learning PHP and I'm programming a  .php Registration webpage, and I want to make sure that the e-mail is valid (if the user doesn't type @ or . he will get a error message).  That's the e-mail part:  $Email = $_POST['email']; $needle = '@'; $search = strpos($Email, $needle);  elseif ($search == FALSE)             {                 echo "Your e-mail is not valid.";             }   How can I make it with multiple letters instead of only @? I want to add the dot (.com) as well, I added it on $needle but it doesnt work. Thanks in advance.
Over the years I have slowly developed a  that validates MOST email addresses correctly, assuming they don't use an IP address as the server part.  I use it in several PHP programs, and it works most of the time.  However, from time to time I get contacted by someone that is having trouble with a site that uses it, and I end up having to make some adjustment (most recently I realized that I wasn't allowing 4-character TLDs).  What is the best regular expression you have or have seen for validating emails?  I've seen several solutions that use functions that use several shorter expressions, but I'd rather have one long complex expression in a simple function instead of several short expression in a more complex function.
When I enter single quote ' in terminal it goes to some other mode, and commands don't execute. What is this mode and when do we use it?  root@sai:~# ' &gt; ls &gt; ' ls : command not found root@sai:~# I've been searching for a quantum algorithm to compute the the inner product between two $n$-qubit quantum states, namely $\langle\phi|\psi\rangle$, which is in general a complex number. One can get $|\langle\phi|\psi\rangle|^2$ through thte SWAP test for multiple qubits, but this is not really the inner product as the information of the real and imaginary parts are lost. I came across this , which claims that the task can be done by simply using CZ gates. I'm not sure if I am mistaken, but it seems to me that such a circuit works for computational basis states, but not for general quantum states. Could somebody help me confirm if this is actually the case? If the above algorithm doesn't work for general quantum states, what algorithm would you suggest? Let be $V$ a vector space over the complex numbers with inner product. Let be $T$ and $S$ linear operators in $V$ with adjoint operators $T^*$, and $S^*$ respectively. I know that it satisfies this: $\left&lt; T(x),y \right&gt;=\left&lt; x,T^{*}(y) \right&gt;$ $\left&lt; S(x),y \right&gt;=\left&lt; x,S^{*}(y) \right&gt;$    $\forall x,y \in V$ But, How can I prove that the adjoint operator of $ST$ is $(ST)^{*}$? And how can I  prove that $(ST)^{*}=T^{*}S^{*}$? What is the integral of $\int e^x\,\sin x\,\,dx$? I'm trying to solve the integral of $\left(\int e^x\,\sin x\,\,dx\right)$ (My solution):  $\int e^x\sin\left(x\right)\,\,dx=$  $\int \sin\left(x\right) \,e^x\,\,dx=$  $\left(\sin(x)\,\int e^x\right)-\left(\int\sin^{'}(x)\,\left(\int e^x\right)\right)$  $\left(\sin(x)\,e^x\right)-\left(\int\cos(x)\,e^x\right)$  $\left(\sin(x)\,e^x\right)-\left(\cos(x)\,e^x-\left(\int-\sin\left(x\right)\,e^x\right)\right)$  $\left(\sin(x)\,e^x\right)-\left(\cos(x)\,e^x-\left(-\sin\left(x\right)\,e^x-\int-\cos\left(x\right)\,e^x\right)\right)$  I don't know how to complete because the solution gonna be very complicated. I will be arriving in Mumbai Terminal T2 on a Turkish Airlines international flight. I have a separately-purchased IndiGo ticket 5 hours later from Terminal 1B (Domestic). In the past I heard of a free bus to transfer.    Is that still the case and if not how do I get to Terminal 1B from Terminal 2? Under Windows, most applications and application data are stored in a special directory known as C:\Program Files (and occasionally C:\Program Files (x86)). What is the Ubuntu/Linux equivalent to this path? Is there even one? Pass Method as Parameter using C# $E(|X-Y|)$ for $X$, $Y$ i.i.d and uniform on $[0,1]$ What is $E|X-Y|$ when $X$, $Y$ are i.i.d and uniform on $[0,1]$?   I want to do something like   $$ E(|X-Y|)=\iint_{x&gt;y}(x-y)\;dxdy+\iint_{y&gt;x}(y-x)\;dxdy=2\iint_{x&gt;y} (x-y)\;dxdy $$  But am not sure how to solve that last double integral or if this setup is right. I have a common scenario in app design, where I need to store an ordered list, and make the ordering easily accessible and adjustable via an application UI.    The ordering operations are simple and operate on only one item at a time - move to top, move to bottom, move up one position, or down one position.  These positioning operations may be interspersed in with typical add / edit / delete list operations.  For discussion, this is a single-user app and db store.  Because the objects can be highly complex, I'd like to avoid caching the entire list client-side, and tracking newly created objects in memory until a big save operation occurs.    I am using MS-SQL almost exclusively on these projects, and I'm wondering if there are db features, SQL features, or design patterns I should be using to better support the management of ordered lists.    My current approach is to use a DECIMAL column to store the list positions, which become fractional during the item move process.  Then I sort the list and re-generate integer positions to normalize list.  Following this operation, it's ready for another item move.   In an example implementation, I create a column named Seq for position tracking.  Once decimal place is enough for the .5 storage.   [Seq] [decimal](10, 1) NOT NULL   When an item is re-positioned in the app UI,    I UPDATE that record with new Seq value I retrieve the full table, sorted ascending by Seq and regenerate all Seq values in the table from a 1-based integer series   The new Seq value is easily calculated-    Move to top = 0 Move to bottom = MAX(Seq) + 1 Move up = subtract 1.5 from the current Seq value Move down = add 1.5 to the current Seq value   As lists get longer, updates get slower, since I'm doing N UPDATE statements, where N is the number of rows in the table, so it seems only suitable for small tables.    Is there some kind of in-built capability for managing an ordered list in SQL or MS-SQL? Is there a means to update multiple rows in one call?    A far more performant approach would be to allow more decimal places, and then position at the median of the two adjacent items, with no re-sequencing on the list.     Move to top = Min(Seq) - 1 Move to bottom = MAX(Seq) + 1 Move up = median of the 2 previous item Seq values Move down = median of the 2 following item Seq values   This approach only requires one SELECT (containing 2 rows max) and one UPDATE.    However with enough re-positions I imagine the field would run out of decimal places. For example, if I start with items at positions 10 and 11, and keep moving items down the list from position 9, they'd be given sequences of 10.5, then 10.25, then 10.125.  After 10 moves, the positions get lengthy... 10.0009765625.    UPDATE #1 - IMPROVED RE-SEQUENCING OF THE LIST  Regarding re-sequencing, I'm more caught up on row_number(), OVER, and WITH capabilities in MS-SQL.  It's nice to find that there's a much smoother way to re-sequence the list in a single UPDATE operation;  with OrderedItems as  (     select         ItemID,         Seq,         row_number() over (order by Seq asc) NewSeq     from          Items ) update OrderedItems set Seq = NewSeq Are there either examples, or a mention of this having happened, of students permanently transferring from one magical school to another in Potterverse?  Canon only please (books/JKR/Pottermore).  Please note that I am only asking about transfers, e.g. you must already be studying in one school. Therefore an example of Malfoys considering sending Draco to Durmstrang is not in scope, since that happened before he attended Hogwarts. Also, guest-studying during Tri-Wizard doesn't count as it wasn't permanent.  Also, if the answer is a "no", please provide evidence (other than "well I read the books before and I don't remember a single case like that", unless you have eidetic memory) from entire canon. A large number of variants of this question were already asked here, including these - , , which are close, but none seem to answer my question. Assume that $n$ balls are thrown randomly and independently into $k$ bins.  What is the probability of finding $x$ empty bins? What is the expectation of the number of empty bins? I've been working with Corel Draw previously and now i use Illustrator more.Still getting used to some of their features though. I want to insert an image into a circle I've drawn but i don't know how to go about it.It is called power clipping in Corel. Any answers would be appreciated. Im confused about fire. The way I see it :   Heat creates (kinetic) energy in mass and this creates stronger vibrations of atoms. When those vibrations are strong enough the electrons interact stronger due to electromagnetic forces. This causes the electrons to fly away. This is the creation of a plasma and the direction of most electrons is the direction of the flame. the shape and heat of the flame depends mainly on the amount of electrons and their velocity ( apart from the source of heat and the considered gas and solid material) the electrons move freely ( but not random ) in the flame. there is a chemical reaction going on that usually produces smoke or such. the entropy increases in all the above 6 steps and the process is repeated. the electromagnetic energy is converted into kinetic energy of the electron and conductivity in the plasma (flame). the moving electrons create an electromagnetic field.   That is more or less how I see it. What steps are ok ?  And the main question , why is there light involved ?  I mean why cant we just have kinetic energy of the electrons and a changing magnetic field ? Why are there photons ? If the electrons are in a high energy state why cant they just move faster instead of emitting a photon ???  Why is the light usually visible ? is that because of our structure of air ?  If the light is an electromagnetic wave why does the flame go up ? does that imply all electromagnetic waves go up ?? But electromagnetic waves are not influanced by gravity or buoyancy are they ??  What is the final destiny of the electrons and photons if the heat is gone ??  I am puzzled by this. The question is to show that for any $x,y \in\Re^n$  $||x+y||\cdot||x-y||\le||x||^2+||y||^2$  with equality if and only if $\langle x,y \rangle= 0.$  I have that $||x+y||^2=||x||^2+2 \langle x,y \rangle+||y||^2$ , which helps me prove equality but I'm lost on how to show this and show that the inequality part. Let $G$ be a finite abelian group and let $\phi: G \rightarrow G$ be a group homomorphism. I am trying to show that there is a positive integer $n$ such that $G \cong \ker(\phi^{n}) \times \phi^{n}(G)$.  I know that since $G$ is abelian we have that $\ker(\phi^{k})$ and $\phi^{k}(G)$ are normal subgroups of $G$ for any $k$  I also suspect we have the following towers which stabilize at $m$ and $m'$  $$\phi(G) \unrhd \phi^{2}(G) \unrhd \cdots \unrhd \phi^{m}(G)=\phi^{m+1}(G)=\cdots$$  $$\ker(\phi) \unlhd \ker^{2}(\phi) \unlhd \cdots \unlhd \ker^{m'}(\phi)=\ker^{m'+1}(\phi)=\cdots$$  I know that if given a group of the form $HK$ where $H$ and $K$ are normal subgroups of $HK$ and $H\cap K=1$ then $H \times K \cong HK$. I want to apply this to this situation but I am unable to show how write $G$ as a product $HK$  Resolution One of the comments directed me to the following article:  The last part of which answers the question. Below is what is says:  Choose $n=\max(m,m')$, then we have for $x \in \ker^{n}(\phi) \cap \phi^{n}(x)$, this means that $x=\phi^{n}(y)$ for some $y \in G$. This gives:  $0=\phi^{n}(x)=\phi^{2n}(y)$ which means that $y \in \ker^{2n}\phi=\ker^{n}{\phi}$. and then we have that $0=x=\phi^{n}(y)$.  The answer below kindly points out that every element $x$ is contained in one of the cosets of $G/\ker^{n}(\phi)$, this means that $x=k+g$ for some $k \in \ker^{n}(\phi)$ and $g \in G$. We also have that $g=\phi^{n}(h)$ for some $h \in G$. Writing $x=k+\phi^{n}(h)$ essentially shows that $G=\ker(\phi^{n}) + \phi^{n}(G)$. Using the fact above, the claim follows. How to run batch file without admin privillege? Which words in a title should be capitalized? Are there any concrete rules that say which words (parts of speech) in a title should start with a capital letter? What would be a correct capitalization for the title of this question? Why are there 2 packages for some applications (e.g. Chromium) in Ubuntu Software? In Windows 8, when Alt+Tab, the desktop would appear as an option to switch to at the end of the list of open programs (thus Alt-Shift-Tab helpfully took you right to the desktop).  In Windows 10 that desktop option is gone. Is there any way to get it back?  I know about Windows+D but Alt+Tab is just more convenient in my opinion. And  also has no desktop and is uglier. Proving that $GF(p^n)$ contains a unique subfield isomorphic to $GF(p^m)$ if and only if $m$ is a divisor of $n$. I am looking to prove that $GF(p^n)$ contains a unique subfield isomorphic to $GF(p^m)$ if and only if $m$ is a divisor of $n$. In the Wikipedia article:    They say that this statement has been proven by E. H. Moore in 1893.  How to go about proving the theorem? I know first I need to generate a subset, prove that it's a subfield, and then assume they are two and show it's unique.  But how to generate it in the first place? Consider the set of polynomials of the form $x^{p^m}-x=0$? Is there a way to show that it's a subfield without checking all the axioms?