How do I make my rule match an exact value of a cookie? I've tried:  RewriteCond %{HTTP_COOKIE} ^its=me$ [NC]  RewriteCond %{HTTP_COOKIE} its=^me$ [NC]  RewriteCond %{HTTP_COOKIE} its="me" [NC]  RewriteCond %{HTTP_COOKIE} its=me [NC]    The last almost works, but matches when extra text is at the end of the value, like "me2". The condition should be true only if the its cookie has an exact value of me, with nothing more before or after.  These values should not match:   you me2 [empty string] [cookie is not set at all]
487
This is a  about Apache's mod_rewrite.   Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as:   Changing HTTP to HTTPS (or the other way around) Changing a request to a page which no longer exist to a new replacement. Modifying a URL format (such as ?id=3433 to /id/3433 ) Presenting a different page based on the browser, based on the referrer, based on anything possible under the moon and sun. Anything you want to mess around with URL   Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask!  How can I become an expert at writing mod_rewrite rules?   What is the fundamental format and structure of mod_rewrite rules? What form/flavor of regular expressions do I need to have a solid grasp of? What are the most common mistakes/pitfalls when writing rewrite rules? What is a good method for testing and verifying mod_rewrite rules? Are there SEO or performance implications of mod_rewrite rules I should be aware of? Are there common situations where mod_rewrite might seem like the right tool for the job but isn't? What are some common examples?   A place to test your rules  The  web site is a great place to play around with your rules and test them. It even shows the debug output so you can see what matched and what did not.
92922
I'm having trouble writing a regular expression that matches valid IPv6 addresses, including those in their compressed form (with :: or leading zeros omitted from each byte pair).    Can someone suggest a regular expression that would fulfill the requirement?  I'm considering expanding each byte pair and matching the result with a simpler regex.
32741
The  states that:     Since 1.0.4, case insensitive regular expressions can be used by prefixing the pattern with ~*.   And gives the example:  map $uri $myvalue {     /aa                   /mapped_aa;     ~^/aa/(?&lt;suffix&gt;.*)$  $suffix; }   I updated to nginx/1.2.7 to make use of this, and naive regexes work okay, but variables don't. When I try the above syntax I get the error:  nginx: [emerg] pcre_compile() failed: unrecognized character after (?&lt; in "^/aa/(?&lt;suffix&gt;.*)$" at "suffix&gt;.*)$"   I also tried the following syntaxes, but none of them worked:  ~^(.*)$  $1; ~^(.*)$  \1;   but neither of them worked either.  Does anyone know how to get variables to work in regular expressions in HttpMapModule?
14665
I've been looking for a simple regex for URLs, does anybody have one handy that works well?  I didn't find one with the zend framework validation classes and have seen several implementations.
64274
It seems there's no way to tell bind that *-foo.example.com should resolve to eg. 10.1.2.3, while *-bar.example.com resolves to 10.2.3.4. Is there any workaround? Can some names eg. resolve with an external program? Or should I change bind to eg. ?  I'm trying to avoid buying another SSL wildcard cert. (With wildcard certs, such as *.example.com, it's not possible to allow dots in the * part.)  Specifying all *-foo or *-bar names in the zone file is not an option, since I need to be able to create both type of addresses on the fly.
23875
What does double slashes often found in URL's mean exactly?  For example:   http://www.example.com/A/B//C/   Please note that I'm not referring to the beginning right after http:.
10243
I'm quite confused about the following regular expressions I found in a shell script:  ${0##*/} ${0%/*}   How do they work?
93853
How would you go about creating a random alpha-numeric string that matches a certain regular expression?  This is specifically for creating initial passwords that fulfill regular password requirements.
19124
I'm currently practicing on a purposely flawed login page, where I have to change the value of a cookie to enter. The cookie is an encrypted and encoded form of a simple JSON string with fields "admin", "username", "password". The admin field is set to 0, and the user/pass fields accepts anything. To login, I have to change this ciphertext such that the admin field is set to 1 when decrypted.  The encryption function works like this:   A raw string is padded, then encrypted with AES-CBC and a random IV. Then, this cipher text appends the IV (concatenation; IV+cipher).  Then, this is Base64 encoded, and returned.   So, to decrypt, we simply decode it with Base64, and split the result so that the 16 first characters are the IV, and the remaining is the ciphertext.   Now, I want to know the ciphertext when one character of the plaintext is changed.   Specifically, in my example:  The following string is encrypted, appended to the IV, and encoded:  {"admin": 0, "username": "admin", "password": "admin"}  This apparently results in the encoded text (found in cookie):  yMqlNejXMclgcU5+wbL40RY/mvIMW+AvguoMvCv0NemhRYzWzs7EQ2DXpvwsGmFynGpNWNyotYBea+P3Z3XZIvMBoMzdMVb/FtWQ+GV/MmA=  I'd like to know what this encoded text / cookie looks like if the plaintext is changed to {"admin": 1, "username": "admin", "password": "admin"} (note, the 0 changed to 1). The username and password can be anything, only the "admin": 1 part is important.  It appears the key is fixed, but the IV is generated at random every time I try to logout and login again.  Is this possible? If so, how?  Thanks!
68001
By default, all browser instances use the same cookie for the same site. Is there a browser that doesn't follow this?  Or is there a Firefox plugin that can "wear" different cookies for a specific site?
16097
I wrote a Javascript RegExp test to detect date string format, I added an redundant "g" flag by mistake and found something interesting.  var s = "2009/03/10"; var regex=/^\d{4}[/]\d{2}[/]\d{2}$/g; alert(regex.test(s)); alert(regex.test(s)); alert(regex.test(s)); alert(regex.test(s));   I got a 'true' followed by a 'false', then another 'true', then another 'false'.  If I use a loop to execute it, I found something more interesting, I got four "true" in IE and Safari, and true,false,true,false in FF, Chrome.  for (var i=0; i&lt;4; i++) {   var s = "2009/03/10";   var regex=/^\d{4}[/]\d{2}[/]\d{2}$/g;   alert(regex.test(s)); }   Does anybody has idea to explain why the Javascript regex behaves like that and what cause browsers return different results? ( related to variable declaration and life scope? )
95809
When doing a search, posts with MathJax code are wrongly formatted.  In this example  all the results look ugly. When taking a closer look at the first post, I notice that the first $ is not regocnized by MathJax as a math-begin, while the second $ (that should denote math-end) is taken as the beginning of math.    Another example:
120013
I want to create user accounts named after a domain name. adduser complains that the usernames need to match the NAME_REGEX regular expression.  adduser: Please enter a username matching the regular expression configured via the NAME_REGEX configuration variable.  Use the `--force-badname' option to relax this check or reconfigure NAME_REGEX.   I can add the users using useradd without complaint.  Is there a reason that I shouldn't modify the regular expression to allow ., - and _?  What characters will cause problems and shouldn't be allowed in usernames?  This is the default NAME_REGEX.  NAME_REGEX="^[a-z][-a-z0-9]*\$"
45470
I'm trying to make a URL with a tilde character (~) in it:  \usepackage{url} ... \url{http://lyle.smu.edu/~tspell/jaws}   It looks right in the resulting PDF, but when clicking on it the browser goes to a wrong URL: http://lyle.smu.edu/%18tspell/jaws  If I type in the browser %7e (escape code for '~') instead of %18 the browser then goes to the correct URL.  Any idea how to get a correct link in the PDF?
3542
I have a value like this:  "Foo Bar" "Another Value" something else   What regex will return the values enclosed in the quotation marks (e.g. Foo Bar and Another Value)?
94801
I have the following C# which simply replaces parts of the input string that look like EQUIP:19d005 into URLs, like this:  input = Regex.Replace(input, @"(EQUIP:)(\S+)", @"&lt;a title=""View equipment item $2"" href=""/EquipmentDisplay.asp?eqnum=$2""&gt;$1$2&lt;/a&gt;", RegexOptions.IgnoreCase);   The HTML ends up looking like this.  &lt;a title="View equipment item 19d005" href="/EquipmentDisplay.asp?eqnum=19d005"&gt;EQUIP:19d005&lt;/a&gt;   The only trouble is that the destination page expects the eqnum querystring to be all UPPERCASE so it returns the correct equipment when eqnum=19D005 but fails if it receives eqnum=19d005.  I guess I can modify and correct EquipmentDisplay.asp's errant requirement of uppercase values however, if possible I'd like to make the C# code comply with the existing classic ASP page by uppercasing the $2 in the Regex.Replace statement above.  Ideally, I'd like the HTML returned to look like this:  &lt;a title="View equipment item 19d005" href="/EquipmentDisplay.asp?eqnum=19D005"&gt;EQUIP:19d005&lt;/a&gt;   Notice although the original string was EQUIP:19d005 (lowercase), only the eqnum= value is uppercased.  Can it be done and if so, what's the tidiest way to do it?
68490
In JavaScript:  encodeURIComponent("©√") == "%C2%A9%E2%88%9A"   Is there an equivalent for C# applications? For escaping HTML characters I used:  txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]",     m =&gt; @"&amp;#" + ((int)m.Value[0]).ToString() + ";");   But I'm not sure how to convert the match to the correct hexadecimal format that JS uses. For example this code:  txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]",     m =&gt; @"%" + String.Format("{0:x}", ((int)m.Value[0])));   Returns "%a9%221a" for "©√" instead of "%C2%A9%E2%88%9A". It looks like I need to split the string up into bytes or something.  Edit: This is for a windows app, the only items available in System.Web are: AspNetHostingPermission, AspNetHostingPermissionAttribute, and AspNetHostingPermissionLevel.