HTML Anchor <a> Tag Grabber(overcome newlines)

Published on Tue Mar 01 2022

Additional matching regexes for
HTML Anchor <a> Tag Grabber(overcome newlines)

HTML Anchor to Markdown Inline Link

Extracts the href and title values from an anchor tag to be placed into an inline Markdown link.

Wikipedia anchor

Match Wikipedia anchor dot-instead-of-percent encoding string.replace(/((?:\.[a-f0-9]{2}){2})/ig, function(match) { return decodeURIComponent(match.replace(/\./g, '%')) });

Remove single, but not repeating newlines, except immediately after a period. (xiTWA2/1)

Intended as a first pass on already word wrapped text, to remove wrap newlines while preserving likely intentional ones. Not *especially* robust.

CSV parsing

matches the exact fields of CSV files supports: qouted fields quoted fields containing commas, doubble quoutes, and newlines empty fields empty records arbitrary white space in, and outside quoted fields

Match a specific CSV field.

Fields terminated by ';' even if the fields are surrounded by " does not accept newlines. Change the central qualifier to get the column. if you want the Xth field write X-1 and use the 3° mathing group OR write X and use the 2° match.

URL supporting ports, GET params and js routing

(http(s)?:\/\/) // http:// or https:// (([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)+(:[1-9]+[0]*)?)(\/?| // basic url f.e. www.wp.pl with obligatory / at end ((\/(#?[a-zA-Z_\-\.])+)*)(\/?| // subfolders or asp files plus possible # for routing or anchor with obligatory / at end \?([a-z]+\=([a-z]+|[a-z]+,[a-z]+)*&)*([a-z]+\=([a-z]+|[a-z]+,[a-z]+)*)\/?)) // http GET parameters with obligatory / at end

Strip multi-line (star) comments from JavaScript, while leaving any CDATA sections intact.

This regular expression removes multi-line (star) comments from JavaScript, while leaving any CDATA sections intact. Use the global (g) modifier to match them all (if you plan to use PHP's preg_replace, the g modifier is not necessary), and use the (s) modifier to make dots match newlines (this will be required in for using with PHP's preg_replace function). This regular expression does not exhaust all possibilities (such as a space between the opening or closing star comment and the CDATA tag), but it functions if the style guidelines are of the more popularized variety.