t-sql batch script parser

Published on Tue Mar 01 2022

Splits t-sql script into separated commands. useful for executing with adocommand object

Additional matching regexes for
t-sql batch script parser

t-sql batch script parser

Splits t-sql script into separated commands. useful for executing with adocommand object

object

Json Object

Command handling

Handles commands like in CMD

Remove GO and split for batch SQL text

Useful for when you need to convert a T-SQL MSSMS Server batch into individual SQL requests by removing the GO between them. e.g. Dim SQLBatches As String() = Regex.Split(text, "(?:\s|\r|\n)+GO\s*(?:\r|\n)", RegexOptions.IgnoreCase)

ip/host:port parser (proxy lists)

simple ip:port or host:port parser capturing ip or host and port, usually used for proxy lists

Css Splitter

Splits the css code into two blocks. (comments|selector block)

Parser for GPG search-key output

Record the output of the batch `gpg --search-keys` commands into variables. For example, get the public key ids or those with `*.amazon.com` email addresses: pubkeyids=$(gpg --batch --keyserver hkp://keyserver.ubuntu.com --search-keys amazon.com 2>&1 | grep -Po '\d+\s*bit\s*\S+\s*key\s*[^,]+' | cut -d' ' -f5) We can automate searching for keys and adding them to the keyring using `bash` parsing that output. As an illustration, I created [the following GitHub gist][1] to host the code below. [1]: https://gist.github.com/mavaddat/a81627ec4680ef5d6c30a9ebdc412037

CSV CIDR subnets

Comma separated CIDR network addresses

Word wrap text

(Directly inspired by https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/ ) This version only splits between words, so lines may wrap earlier than the given maximum. Passes existing linefeed through "as‐is", so probably not useful for reflowing already wrapped text

Find PHP object variables

Find PHP object variables, and replace them with (array)brackets.