I'm converting my ASP.NET MVC application to Core! One of my problem is converting 'Url.Action(MVC.Account.ResetPasswordCode())' to 'Url.Action("ResetPasswordCode","Account")'. I need to find all 'MVC.Foo.Bar()' or  'MVC.Foo.Bar.Baz()' matches by regular expressions.  I have tried this patterns in regex.  "(MVC.)(.*?)(\\(\\))"   But result is wrong.  Thanks.
591
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?
52565
I'm currently using log4net in my ASP.NET MVC application to log exceptions.  The way I'm doing this is by having all my controllers inherit from a BaseController class.  In the BaseController's OnActionExecuting event, I log any exceptions that may have occurred:  protected override void OnActionExecuted(ActionExecutedContext filterContext) {     // Log any exceptions     ILog log = LogManager.GetLogger(filterContext.Controller.GetType());      if (filterContext.Exception != null)     {         log.Error("Unhandled exception: " + filterContext.Exception.Message +             ". Stack trace: " + filterContext.Exception.StackTrace,              filterContext.Exception);     } }   This works great if an unhandled exception occurred during a controller action.  As for 404 errors, I have a custom error set up in my web.config like so:  &lt;customErrors mode="On"&gt;     &lt;error statusCode="404" redirect="~/page-not-found"/&gt; &lt;/customErrors&gt;   And in the controller action that handles the "page-not-found" url, I log the original url being requested:  [AcceptVerbs(HttpVerbs.Get)] public ActionResult PageNotFound() {     log.Warn("404 page not found - " + Utils.SafeString(Request.QueryString["aspxerrorpath"]));      return View(); }   And this also works.  The problem that I'm having is how to log errors that are on the .aspx pages themselves.  Let's say I have a compilation error on one of the pages or some inline code that will throw an exception:  &lt;% ThisIsNotAValidFunction(); %&gt; &lt;% throw new Exception("help!"); %&gt;   It appears that the HandleError attribute is correctly rerouting this to my Error.aspx page in the Shared folder, but it is definitely not being caught by my BaseController's OnActionExecuted method.  I was thinking I could maybe put the logging code on the Error.aspx page itself, but I'm unsure of how to retrieve the error information at that level.
20352
Is it possible to detect a valid regular expression with another regular expression?  If so please give example code below.
43149
I did a search for A$, but a whole bunch of results containing "Å", "A's" and "as" were return, could not find one containing "A$":    Same thing for other special characters such as "#".
52427
How do I escape a string in SQL Server's stored procedure so that it is safe to use in LIKE expression.  Suppose I have an NVARCHAR variable like so:  declare @myString NVARCHAR(100);   And I want to use it in a LIKE expression:  ... WHERE ... LIKE '%' + @myString + '%';   How do I escape the string (more specifically, characters that are meaningful to LIKE pattern matching, e.g. % or ?) in T-SQL, so that it is safe to use in this manner?  For example, given:  @myString = 'aa%bb'   I want:  WHERE ... LIKE '%' + @somehowEscapedMyString + '%'   to match 'aa%bb', 'caa%bbc' but not 'aaxbb' or 'caaxbb'.
118546
Is there a regular expression that matches valid regular expressions?   (I know there are several flavors of regexps. One would do.)
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?
14848
Our URLs will be created by the user's content.  Eg:  www.example.com/bar-1234/i-went-to-baz-4321  The "i went to baz" portion is user generated, included with the aim of being helpful to the person viewing the URL and also to possibly contain useful keywords for search engines.  However, the string that forms that portion is user editable. So it could become:  www.example.com/bar-1234/we-drove-to-baz-4321  AFAICT the canonical URL should be:  www.example.com/bar-1234/4321  The string portion is discarded by the controller, which means that there's potential for duplicate content from limitless URLs!  So, my question is, does it matter if my canonical URL is 'non SEO friendly'?  It seems logical to me to provide search engines with the "id only" version of the URL which is always consistent, but the canonical URL is the one that appears in search results, so is there any benefit from trying to use more 'SEO friendly' URLs?
3192
Initial Googling indicates that there's no built-in way to do regular expressions in an Objective-C Cocoa application.  So four questions:   Is that really true? Are you kidding me? Ok, then is there a nice open-source library you recommend? What are ways to get close enough without importing a library, perhaps with the NSScanner class?
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?
27549
Asp.net-MVC now allows for implicit binding of DateTime objects. I have an action along the lines of  public ActionResult DoSomething(DateTime startDate)  {  ...  }  This successfully converts a string from an ajax call into a DateTime. However, we use the date format dd/MM/yyyy; MVC is converting to MM/dd/yyyy. For example, submitting a call to the action with a string '09/02/2009' results in a DateTime of '02/09/2009 00:00:00', or September 2nd in our local settings.  I don't want to roll my own model binder for the sake of a date format. But it seems needless to have to change the action to accept a string and then use DateTime.Parse if MVC is capable of doing this for me.  Is there any way to alter the date format used in the default model binder for DateTime? Shouldn't the default model binder use your localisation settings anyway?
64797
Situation: It started out as me  for the literal string C-c in  but it ended up omitting the - sign and showing results which contained the strings C/C++ and C &amp; C++.  is an example of a post which contains that string of characters (yet fails to show up in the results).  Things I've tried:   post suggests that I can use the undocumented code: operator, but when I do that, it just wraps the whole term in double quotes like .  As @terdon in Unix &amp; Linux chat has , using this  does yield some relevant results, but it doesn't show me  that is supposed to be there. edit: It appears that the Symbolhound query no longer returns that result.  Finally,  says that you can search for literal characters, but as you can see:    Quoted phrases are exact matches except for case-sensitivity, for example, you can search  or .  The second example (symbols) leads to 0 results.  So by now I assume that the search engine has changed (but the old documentation still lingers on this site). Is there a method for me to search for strings that include special (or is it literal?) characters?
65647
Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails   Is it possible to have the character class match a "-" ?
32215
I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to change this behavior, but as I said, I've never really done much with regular expressions.  string compare = "1234=4321"; Regex regex = new Regex(@"[\d]");  if (regex.IsMatch(compare)) {      //true }  regex = new Regex("[0-9]");  if (regex.IsMatch(compare)) {      //true }   In case it matters, I'm using C# and .NET2.0.
4355
For example, this regex  (.*)&lt;FooBar&gt;   will match:  abcde&lt;FooBar&gt;   But how do I get it to match across multiple lines?  abcde fghij&lt;FooBar&gt;
90488
I would like to redirect a URL with uppercase characters http://localhost/A/B to a lowercase version http://localhost/a/b using the .htaccess file. Using regex I can capture A and B but is it possible to convert them to lowercase?
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.