I am new to regex and I am burning hours just to get it right. I need to allow these patterns  NPA-XXX-XXXX (NPA) XXX-XXXX NPAXXXXXXX   where NPA = numbers 0 to 9    and X is also any number 0 to 9  so this is valid  123-456-7890 1234567890 (123) 456-7890   but not this  (123)-456-7890   // because there is a dash after closing parenthesis (123)456-7890    // because there is no space after closing parenthesis QWE-456-7890  // because there are one or more alpha characters   I use this  Regex r = new Regex(@"^?\(?\d{3}?\)??-??\(?\d{3}?\)??_??\(?\d{4}?\)??-?$");   from System.Text.RegularExpressions  What would be the regular expression that would match the valid?
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:   1-234-567-8901 1-234-567-8901 x1234 1-234-567-8901 ext1234 1 (234) 567-8901 1.234.567.8901 1/234/567/8901 12345678901   I'll answer with my current attempt, but I'm hoping somebody has something better and/or more elegant.
Clear Android Market Search History? Any thoughts on how one might clear the Android Marketplace search history? For instance, if I recently searched for an android app in the marketplace, the marketplace search maintains a history list of which apps/keywords that I have recently looked for.    Thanks in advance! Adding two numbers concatenates them instead of calculating the sum I have $a,b,c\in\mathbb{Q}$ not all zero. ($a^2+b^2+c^2\ne 0$), I want to show that the following determinant is then non-zero. I failed to arrive at an appropriate form of the polynomial. Help please. $$\left|\begin{bmatrix} a &amp; 2c &amp; 2b\\b &amp; a &amp; 2c\\ c &amp; b &amp; a\end{bmatrix}\right| = a^3+2 b^3-6 a b c+4 c^3$$    Second question, what is the easiest way to argue that $\{1,\sqrt[3]{2},(\sqrt[3]{2})^2\}$ is linearly independent in $\mathbb{Q}$?    Motivation: Prove that $\mathbb{Q}[\sqrt[3]{2}] = \{a+b\sqrt[3]{2}+c(\sqrt[3]{2})^2\;|\;a,b,c\in\mathbb{Q}\}$ forms a field.   Proof: Since $\mathbb{Q}[\sqrt[3]{2}] \subset \mathbb{R}$, we prove $\mathbb{Q}[\sqrt[3]{2}]$ is a subfield of $(\mathbb{R},+,\cdot)$    $\forall (a+b\sqrt[3]{2}+c(\sqrt[3]{2})^2)\in \mathbb{Q}[\sqrt[3]{2}]\backslash\{0\}.$ We want to find $(a+b\sqrt[3]{2}+c(\sqrt[3]{2})^2)$ such that    $(a+b\sqrt[3]{2}+c(\sqrt[3]{2})^2)(d+e\sqrt[3]{2}+f(\sqrt[3]{2})^2) =$ $ (ad+2ec+2bf)+(ae+bd+2cf)\sqrt[3]{2}+(af+cd+be)(\sqrt[3]{2})^2 = 1$    Since $\{1,\sqrt[3]{2},(\sqrt[3]{2})^2\}$ is linearly independent (?) over $\mathbb{Q}$, we show there is unique solution to: $$\begin{bmatrix} a &amp; 2c &amp; 2b\\b &amp; a &amp; 2c\\ c &amp; b &amp; a\end{bmatrix} \cdot \left[\begin{array}{l l} d\\e\\f \end{array}\right] = \left[\begin{array}{l l} 1\\0\\0 \end{array}\right] $$ Which is equivalent in showing the determinant is non-zero $$\left|\begin{bmatrix} a &amp; 2c &amp; 2b\\b &amp; a &amp; 2c\\ c &amp; b &amp; a\end{bmatrix}\right| = a^3+2 b^3-6 a b c+4 c^3=(?)$$    By subfield test, 1)2)3)4) is enough to say that $(\mathbb{Q}[\sqrt[3]{2}],+,\cdot)$ is a subfield of $(\mathbb{R},+,\cdot)$ therefore a field.  EDIT: If you have shorter way that prove the proposition without touching my 2 questions, that is even better. Every element outside the maximal ideal of a local ring is a unit A homework question from my algebra class asks:     Show that in a local ring $R$ with maximal ideal $M$, every element outside $M$ is a unit.   My argument is that since $M$ is maximal $R /M $ is a field and so for any $ x \in R \backslash M $, $ x + M $ has a multiplicative inverse, which implies $ x $ is a unit.  I don't see where we need the fact that $R$ is a local ring. Prove or disprove: if $\sum\limits_{n=0}^∞a_n$ converges and $\lim\limits_{n\to\infty}b_n =0$, then $\sum\limits_{n=0}^{\infty}a_n b_n$ converges. What is the purpose of the thin wire at the top of power transmission lines? I know a power transmission line carries usually two sets of 3 phase conductors. But I have noticed a relatively thin wire at the center-top of the power transmission line. What is the purpose of this thin wire? Is "Smaug" pronounced "Smog"? Did Tolkien the linguist intend for the name of the dragon Smaug to be pronounced "Smog" [IPA: /smɒɡ/ or /smɔːɡ/]? The trailer for the second installment of The Hobbit trilogy pronounces the word (pronounced 'sma-ow-g' [IPA: /smaʊɡ/]) entirely differently than the way I have been reading it for all these many years. Customize feed on stack exchange android app How to Store Fresh Herbs How do I install VMware player on a Mac os X? Why does just splitting an Ethernet cable not work? I thought the Ethernet is logically a one-line communication bus (for argument's sake, I am excluding hubs). All machines attached on the bus hears the same signals and the machines themselves try to avoid collisions by randomly backing off.    If so, why would splitting one Ethernet line from my home router into two and connecting two computers not work? Why do I have to add a switch to it?  What the Internet said would not work.                                                             +----------+                                                +----------&gt;|computer 1|                                                |           +----------+     +------------------+       +---------------+     |4 port home router+------&gt;|simple splitter|     +------------------+       +---------------+                                                |           +----------+                                                +----------&gt;|computer 2|                                                            +----------+   What the Internet said I should do                                                             +----------+                                                +----------&gt;|computer 1|                                                |           +----------+     +------------------+       +---------------+     |4 port home router+------&gt;|    switch     |     +------------------+       +---------------+                                                |           +----------+                                                +----------&gt;|computer 2|                                                            +----------+   Is this because of the signal degradation (reduced electric current)?    Thank you for all the answers! The reason why I did not just use the two ports of my home router is...  The 4-port gigabit router is in my room, and I had put a computer in another room (also my room, though). Since a wired network is far more reliable and secure, I had bought a long Ethernet cable and and connected the computer to the router. Now I was thinking about adding another computer to that room. I could buy another long Ethernet cable, but then there will be two cables between the rooms. The one line already is a minor annoyance, so I thought if I could share the one line between the two computers in that room. A switch would work, but it requires power and is a little bit pricey. That is why I wondered why it would not work to simply split the physical Ethernet cable.  Apparently I do not completely understand how Ethernet and a switch work. I just have some bit of knowledge I heard in my college class. How to change the snapping increment in different units? I would like to know how to change the increments used for snapping transforms.  This would be useful in a number of situations but my problem now is that when I change the units it does not scale the snapping increments to match.  So when holding down ctrl the cube snaps from here:    To here:    I would like it to snap to the 1 foot grid, or possibly any other amount I find useful.  It would also be nice to be able to change the rotation snap as well. Suppose Alice chooses a random Prime $p$ and a random private Key $a \in \mathbb{Z}^*_p$. By accident, she also chooses a random number $g \in \mathbb{Z}^*_p$, which is not a generator of $\mathbb{Z}^*_p$ and therefore  $$\langle g\rangle \subset \mathbb{Z}^*_p$$  as opposed to $\langle g\rangle = \mathbb{Z}^*_p$, which would yield a valid key. Alice then computes $A \equiv g^a \pmod{p} $ and publishes the Tuple $(p,g,A)$ as her public key.  Bob now encrypts a message $M$ using Alices public key by computing  $$C_1 = g^b \pmod{p}$$ $$C_2 = M \cdot A^b \pmod{p}$$  Is it possible for an attacker (Eve) to distinguish a “real” ciphertext $(C_1,C_2)$ from a random ciphertext $(Z_1,Z_2) \stackrel{$}{\longleftarrow} \mathbb{Z}^*_p$ with significant advantage (say $Adv \geq \frac12$)?    Edit: I guess it should be enough to show, that the ciphertext cannot be random, if  $$\langle g \rangle \neq \langle C_1 \rangle \quad(\text{or $Z_1$, respectively})$$  But how can Eve check for this property efficiently? Can someone point me in the right direction here?    Edit: A real-world situation where this flaw occurred Where do executables look for shared objects at runtime? I understand how to define include shared objects at linking/compile time. However, I still wonder how do executables look for the shared object (*.so libraries) at execution time.  For instance, my app a.out calls functions defined in the lib.so library. After compiling, I move lib.so to a new directory in my $HOME.  How can I tell a.out to go look for it there? Why does Linux show both more and less memory than I physically have installed? How to use Whatsapp mobile application on Ubuntu Touch? In my Android I have "Whatsapp" application running. But mobile freak I am not, and specially the mobile keyboards.  So how can I run my same application, same account from my Ubuntu desktop PC?   Follow up:  Just to do keyboard routing, i have used . Which allows me to takeover the Android input fields access via web link to type in my PC keyboard, and then it re-route the keys to Mobile.  Features:   Allows me to copy and paste large texts to Android input fields without using the keyboard of Android but simply using my Desktop PC, via web link http://android.ip.address.goes.here:port/ Allows me to have key submit which is similar to key press of mobile set itself   At-least works without having mobile in rooted. Hope it helps you!! How can I reset $PATH to its default value in Ubuntu? I accidentally unset all the directories of $PATH while trying to add a new one in ~/.bashrc. I opened a new terminal window as I was editing and now $PATH is empty. I'm worried if I boot from another drive to find the $PATH I won't be able to boot into this drive again.  Basically, what is the default result of echo $PATH? How do I install the latest stable version of Thunderbird? The ship flying away from Rey in her flashback of being left on Jakku looks like one of the ships in the group that takes her away when she is captured.  If so, and it is a First Order ship that dropped her off, this is an interesting Easter egg. Word for resembling the truth How do we refer to the act of resembling the truth, regardless if it is indeed the truth?  Some context: suppose you are watching a film and the story bears a striking resemblance to "real life". Perhaps you remember similar events from your own background or the story has a strong internal coherence. So you feel that the story could be true, even though you know it is fictional. Or, as the legend has it, when Michelangelo finished his "Pietà" and the sculpture seemed so "real" and "natural" to him, that he was amazed that the sculpture couldn't talk. One last example: you hear the promises of a politician in election campaign and he seems to be telling the truth, but of course you have no way to figure out, beforehand, if he is being honest or not.  The word "likelihood" comes to mind, but this word suggests some kind of numerical (even statistical) evaluation, which is akin to "probability". The word I am looking for describes the feeling you get, which leads to a subjective "binary" judgement (either it resembles the truth or not).  In Portuguese, such word is "verossimilhança" (from Latin verum, truth + similis, similar).