Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Regex



  Regex vs IndexOf in Java.

Overview The author of these articles Are C# .Net Regular Expressions Fast Enough for You? and .Net Regex: Can Regular Expression Parsing be Faster than XmlDocument or Linq to Xml? recently pointed out to me that he had found that Regular expressions were at least as fast or faster than the alternatives in C#. However it has been my experience that regular expressions in Java were slower. It is hard for me to say why this might be different in Java and C# or even if these are fair compari...

   Java,indexOf,Regular Expression,Efficiency     2012-01-03 10:58:52

  A Perl Regular Expression That Matches Prime Numbers

perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"' Can you figure out how it works? I give an explanation below, but try to figure it out yourself. Here is what happens when you run it: $ perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"' 1 2 2 is prime 3 3 is prime 4 5 5 is prime 6 7 7 is prime 8 9 10 11 11 is prime Here is how it works. First, the number is converted in its unary representation by (1x$_). For example, the number 5 gets converted into 1x5, which is ...

   Perl,Regex,Regular expression,Prime number,One line     2011-12-26 08:42:00

  The Greatest Regex Trick Ever (Simplified)

There is a post which is really hot recently which showcased a best ever regular expression trick. In this post, it provides a trick which can be adapted to situations where one wants to match some patterns desired and exclude the patterns undesired. In simple, the trick is : Pattern not desired | (Pattern desired) Then taking the group 1 match of the capturing group of matched. This group will contain the strings matching the desired patterns. Have to say this trick is really neat and brilliant...

   REGULAR EXPRESSION,PROGRAMMING,JAVA     2015-10-01 21:59:05

  Fuzzy search algorithm in Sublime Text

Fuzzy string searching is the technique of finding strings that match a pattern approximately (rather than exactly. In many editors, we can easily find the Find menu item to do exact matching. While in Sublime Text and some other editors, we can use fuzzy string searching as well if we just want to have an approximate match. There is some algorithm implemented in Sublime Text to implement achieve this. First the search query is split into characters, join them with a regex wildcard, and then run...

   Sublime Text,Fuzzy search     2013-10-14 22:49:38

  Greedy and Nongreedy Matching in a Regular Expression

By default, pattern matching is greedy, which means that the matcher returns the longest match possible. For example, applying the pattern A.*c to AbcAbcA matches AbcAbc rather than the shorter Abc. To do nongreedy matching, a question mark must be added to the quantifier. For example, the pattern A.*?c will find the shortest match possible. COPY // Greedy quantifiers String match = find("A.*c", "AbcAbc"); // AbcAbc match = find("A.+", "AbcAbc"); // AbcAbc // Nongreedy quantifier...

   Regular expression,Pattern match,Greedy,     2011-08-09 12:42:28

  Getting started with C++ TR1 regular expressions

Overview This article is written for the benefit of someone familiar with regular expressions but not with the use of regular expressions in C++ via the TR1 (C++ Standards Committee Technical Report 1) extensions. Comparisons will be made with Perl for those familiar with Perl, though no knowledge of Perl is required. The focus is not on the syntax of regular expressions per se but rather how to use regular expressions to search for patterns and make replacements. Support for TR1 ext...

   Regular expression,Replace,TR1,Extension     2011-08-14 07:25:20

  How Many C Programs Are There?

If I choose a size S, can you tell me how many valid C programs exist that are no larger than that size? I’m actually interested in the answer — it’ll help me make a point in a paper I’m writing. Shockingly, the Internet (or at least, the part of it that I looked at based on a few searches) does not provide a good answer. Let’s start with a few premises: Since it would be exceedingly difficult to construct the exact answer, we’re looking for a respe...

   C Progra,Number,Statistic,Calculation     2012-02-22 05:18:32

  Write high quality JavaScript and CSS with SublimeLinter

SublimeLinter is a plugin for one of the front end editor--Sublime Text, it is used to highlight those syntax not conforming to standard or wrong, it supports JavaScript,CSS,HTML,Java,PHP,Python,Ruby and some more.This article will introduce how to configure SublimeLinter in Windows to validate JavaScript and CSS codes. Preparation Install Sublime Text package control tool : http://wbond.net/sublime_packages/package_control Install SublimeLinter with Sublime Text package control tool :https://gi...

   SublimeLinter,Sublime Text,Validation     2013-06-14 23:24:51

  What are some popular myths in software development?

This article is summarized from a question on Quora .The question is         What are some popular myths in software development?Here is the answer which received most votes given by a guy named Lee Semel,. Some of the most prevalent myths are:The Waterfall Method of design, the idea that it is both possible, efficient and good practice to completely specify a system before building it, and to execute the steps of a software project sequentially rather than iter...

   Software design,Myths,Waterfall model     2012-05-02 04:52:01

  Go Error Best Practice

Being indulged in Go for quite a while and having implemented web-related programs, grpc interfaces and Operators, I seem to be an advanced beginner now. However, I am still a raw hand in production-environmental debugging, which is cumbersome if done by querying logs or error messages. Imagine the scenario that a full-text search is called when the specific location of the error log is missing. Then what happens when those error logs are not only in one place? Yes, my error logs can no longer h...

   GO ERROR,ERROR HANDLING     2021-10-07 07:38:28