Posts

Showing posts with the label regular expression

Regular expressions tricks and tips

Regex: Literal characters:  Alphanumeric character: itself \o: null character \t: tab \n: newline \v: vertical tab \f: form feed \r: carriage return \x nn: Latin character specified by a hexadecimal number \u xxxx: Unicode character specified by the hexadecimal number \c X: Control character  Character classes:  /[abc]/-  Any of a, b or c. /[^abc]/- None of a, b and c. /[a-z]/- Any char from a to z. /[a-zA-Z0-9]/- Any char from a-z, A-Z or 0-9. Note: ^ and $ have different meaning inside character classes. ^ means negation and $ behaves like a usual dollar symbol Eg: /a[b$]/: a$ or ab  Clasess: /w:  /[a-zA-Z0-9_]/ Any char from a-z, A-Z or 0-9. /W:  /[^a-zA-Z0-9_]/ Any char other than a-z, A-Z or 0-9. /s: Unicode whitespace /S: Any char other than whitespace charac /d: /[0-9]/ Any ascii digit /D: /[^0-9]/  [\b]: A literal backspace Repetition: {n,m}: Match the previous item at least n times but no more...