Regex for PascalCased words (aka camelCased with leading uppercase letter)

([A-Z][a-z0-9]+)+ Assuming English. Use appropriate character classes if you want it internationalizable. This will match words such as “This”. If you want to only match words with at least two capitals, just use ([A-Z][a-z0-9]+){2,} UPDATE: As I mentioned in a comment, a better version is: [A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]* It matches strings that start with an uppercase letter, … Read more

grep regex whitespace behavior

This looks like a behavior difference in the handling of \s between grep 2.5 and newer versions (a bug in old grep?). I confirm your result with grep 2.5.4, but all four of your greps do work when using grep 2.6.3 (Ubuntu 10.10). Note: GNU grep 2.5.4 echo “foo bar” | grep “\s” (doesn’t match) … Read more

How to validate email id in angularJs using ng-pattern

If you want to validate email then use input with type=”email” instead of type=”text”. AngularJS has email validation out of the box, so no need to use ng-pattern for this. Here is the example from original documentation: <script> function Ctrl($scope) { $scope.text=”[email protected]”; } </script> <form name=”myForm” ng-controller=”Ctrl”> Email: <input type=”email” name=”input” ng-model=”text” required> <br/> <span … Read more

Set RewriteBase to the current folder path dynamically

Here is one way one can grab the RewriteBase in an environment variable which you can then use in your other rewrite rules: RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ – [E=BASE:%1] Then you can use %{ENV:BASE} in your rules to denote RewriteBase, i.e.: #redirect in-existent files/calls to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . %{ENV:BASE}/index.php [L] Explanation: … Read more

Bash – Regex for HTML contents

Don’t parse XML/HTML with regex, use a proper XML/HTML parser. theory : According to the compiling theory, HTML can’t be parsed using regex based on finite state machine. Due to hierarchical construction of HTML you need to use a pushdown automaton and manipulate LALR grammar using tool like YACC. realLife©®™ everyday tool in a shell … Read more