Regexes for usage in Text editor

Date: 2018-05-29
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Replace javascript functions with anonymous functions
Find: function\((.*?)\) {
Replace: ($1) =>
// Get JSON key/values (simple variant, use nested searches on values)
Find: "(.*?)"\s*?\:\s*(.*+)
// Find basic JSON key/values (2)
Find: "(.*?[^\\])":\s*([^,\[\]\{\}\n]*)
// Convert TSV / CSV to JSON key value
Find: ^(.*?)\t(.*?)$
Replace: "$1": "$2",
// Basic email regex
Find: \b[\w._]+@[\w._]+\.[\w._]+\b
// Basic url regex
Find: (?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.#]+
// Find firstname and surname or lastname
Find: \b([\w-]+)\s(.*?)\s?([A-Z][\w- ]+)\b
// Find all public properties in a C# class
Find: public [^\s]+ ([^\s]+)\s+[;{]
// Find all public properties in a C# class
Find: public [^\s]+ ([^\s]+)\s+[;{].*}
// Replace for mapping to this
Replace: $1 = param.$1;
// Replace for constructor mapping
Replace: $1 = $1,
let re = '';
let str = '';
let getMatches = (re, str) => {
let match, matches = [];
while (match = re.exec(str)) {
matches.push(match[1]);
}
return matches;
};
let convert = (match) => {
var p = match[0];
return `${p} = ${p},\r\n`;
};
let convertAll = () => {
let matches = getMatches(re, str);
return matches.map(convert).join();
};
// Replace javascript functions with anonymous functions Find: function\((.*?)\) { Replace: ($1) => // Get JSON key/values (simple variant, use nested searches on values) Find: "(.*?)"\s*?\:\s*(.*+) // Find basic JSON key/values (2) Find: "(.*?[^\\])":\s*([^,\[\]\{\}\n]*) // Convert TSV / CSV to JSON key value Find: ^(.*?)\t(.*?)$ Replace: "$1": "$2", // Basic email regex Find: \b[\w._]+@[\w._]+\.[\w._]+\b // Basic url regex Find: (?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.#]+ // Find firstname and surname or lastname Find: \b([\w-]+)\s(.*?)\s?([A-Z][\w- ]+)\b // Find all public properties in a C# class Find: public [^\s]+ ([^\s]+)\s+[;{] // Find all public properties in a C# class Find: public [^\s]+ ([^\s]+)\s+[;{].*} // Replace for mapping to this Replace: $1 = param.$1; // Replace for constructor mapping Replace: $1 = $1, let re = ''; let str = ''; let getMatches = (re, str) => { let match, matches = []; while (match = re.exec(str)) { matches.push(match[1]); } return matches; }; let convert = (match) => { var p = match[0]; return `${p} = ${p},\r\n`; }; let convertAll = () => { let matches = getMatches(re, str); return matches.map(convert).join(); };
// Replace javascript functions with anonymous functions
Find:    function\((.*?)\) {
Replace: ($1) =>

// Get JSON key/values (simple variant, use nested searches on values)
Find:    "(.*?)"\s*?\:\s*(.*+)
// Find basic JSON key/values (2)
Find:    "(.*?[^\\])":\s*([^,\[\]\{\}\n]*)

// Convert TSV / CSV  to JSON key value
Find:    ^(.*?)\t(.*?)$
Replace: "$1": "$2",

// Basic email regex
Find: \b[\w._]+@[\w._]+\.[\w._]+\b
// Basic url regex
Find: (?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.#]+
// Find firstname and surname or lastname
Find: \b([\w-]+)\s(.*?)\s?([A-Z][\w- ]+)\b


// Find all public properties in a C# class
Find:    public [^\s]+ ([^\s]+)\s+[;{]

// Find all public properties in a C# class
Find:    public [^\s]+ ([^\s]+)\s+[;{].*}
// Replace for mapping to this
Replace: $1 = param.$1;
// Replace for constructor mapping
Replace: $1 = $1,

let re = '';
let str = '';

let getMatches = (re, str) => {
    let match, matches = [];
    while (match = re.exec(str)) {
        matches.push(match[1]);
    }
    return matches;
};

let convert = (match) => {
    var p = match[0];
    return `${p} = ${p},\r\n`;
};

let convertAll = () => {
    let matches = getMatches(re, str);
    return matches.map(convert).join();
};
11150cookie-checkRegexes for usage in Text editor
0 of 2000 max characters.