- The PCRE flavour of RegEx is used here.
- Append the
i
modifier to the end of the regex to make any pattern case-insensitive.
| Purpose | Description | RegEx | Example |
# Sort a list of dictionary objects by a key - case sensitive | |
from operator import itemgetter | |
mylist = sorted(mylist, key=itemgetter('name')) | |
# Sort a list of dictionary objects by a key - case insensitive | |
mylist = sorted(mylist, key=lambda k: k['name'].lower()) |
import gdata | |
import json | |
import requests | |
# More examples: | |
# https://github.com/millioner/Python-contact-importer/blob/master/contact_importer/providers/google.py | |
# https://github.com/jtauber/django-friends/blob/master/friends/importer.py | |
# GData with access token | |
token = gdata.gauth.OAuth2Token( |
error_page 500 /500.html; | |
location /500.html{ | |
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}'; | |
} | |
error_page 502 /502.html; | |
location /502.html{ | |
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}'; | |
} |
public class StringSearch { | |
public static int getSubstringStartIndex(String text, String pattern) { | |
int n = text.length(); | |
int m = pattern.length(); | |
for (int startIndex = 0; startIndex <= ( n - m ); ++startIndex) { | |
int i = 0; | |
for (i = 0; i < m; ++i) { | |
if (pattern.charAt(i) != text.charAt(startIndex + i)) { |
Used for gist name. |