How to ignore acute accent in a javascript regex match?

The standard ecmascript regex isn’t ready for unicode (see So you have to use an external regex library. I used this one (with the unicode plugin) in the past : In your case, you may have to escape the char é as \u00E9 and defining a range englobing e, é, ê, etc. EDIT … 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

How to use RegexIterator in PHP

There are a couple of different ways of going about something like this, I’ll give two quick approaches for you to choose from: quick and dirty, versus longer and less dirty (though, it’s a Friday night so we’re allowed to go a little bit crazy). 1. Quick (and dirty) This involves just writing a regular … Read more

Remove repeating character

Use backrefrences echo preg_replace(“/(.)\\1+/”, “$1”, “cakkke”); Output: cake Explanation: (.) captures any character \\1 is a backreferences to the first capture group. The . above in this case. + makes the backreference match atleast 1 (so that it matches aa, aaa, aaaa, but not a) Replacing it with $1 replaces the complete matched text kkk … Read more

How to escape a string for use in Boost Regex

. ^ $ | ( ) [ ] { } * + ? \ Ironically, you could use a regex to escape your URL so that it can be inserted into a regex. const boost::regex esc(“[.^$|()\\[\\]{}*+?\\\\]”); const std::string rep(“\\\\&”); std::string result = regex_replace(url_to_escape, esc, rep, boost::match_default | boost::format_sed); (The flag boost::format_sed specifies to use the … Read more