PCRE Regex to SED

Want PCRE (Perl Compatible Regular Expressions)? Why don’t you use perl instead? perl -pe ‘s/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g’ \ <<< “My email is abc@example.com” Output: My email is [emailaddr] Write output to a file with tee: perl -pe ‘s/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g’ \ <<< “My email is abc@example.com” | tee /path/to/file.txt > /dev/null

Linker error LNK2038: mismatch detected in Release mode

Your app is being compiled in release mode, but you’re linking against the debug version of PCRE, which had /MTd (or similar) set, thus causing the mismatch in iterator debugging level in the CRT. Recompile PCRE in release mode to match your own application. The detect_mismatch pragma in VS 2010 is what causes this error … Read more

Apache installation; libpcre error

1. Download PCRE from PCRE.org 2. Compile it with a prefix and install it: ./configure –prefix=/usr/local/pcre make make install 3. Go back to where your Apache installation is and compile Apache with PCRE: –with-pcre=/usr/local/pcre

Invert match with regexp [duplicate]

Okay, I have refined my regular expression based on the solution you came up with (which erroneously matches strings that start with ‘test’). ^((?!foo).)*$ This regular expression will match only strings that do not contain foo. The first lookahead will deny strings beginning with ‘foo’, and the second will make sure that foo isn’t found … Read more

Unicode Regex; Invalid XML characters

I know this isn’t exactly an answer to your question, but it’s helpful to have it here: Regular Expression to match valid XML Characters: [\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD] So to remove invalid chars from XML, you’d do something like // filters control characters but allows only properly-formed surrogate sequences private static Regex _invalidXMLChars = new Regex( @”(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFEFF\uFFFE\uFFFF]”, RegexOptions.Compiled); … Read more

Reference – What does this regex mean?

The Stack Overflow Regular Expressions FAQ See also a lot of general hints and useful links at the regex tag details page. Online tutorials RegexOne ↪ Regular Expressions Info ↪ Quantifiers Zero-or-more: *:greedy, *?:reluctant, *+:possessive One-or-more: +:greedy, +?:reluctant, ++:possessive ?:optional (zero-or-one) Min/max ranges (all inclusive): {n,m}:between n & m, {n,}:n-or-more, {n}:exactly n Differences between greedy, … Read more