Home:ALL Converter>String Manipulation / Regex

String Manipulation / Regex

Ask Time:2020-05-01T01:57:36         Author:Marcel Goldhardt

Json Formatter

I have a NVARCHAR(MAX) column which stores a log stream. What I need is to extract some values at the select statement level. As I cannot apply a regex without CLR, what would be the solution using some "string manipulation" functions?

For example, I might have this value in the Log column:

$CF_NONPROD_USERNAME -p $CF_NONPROD_PASSWORD -o $ORG -s $SPACE\u001B[0;m\nAPI endpoint: https://api.server02.pcf.com/\nAuthenticating...\nOK\n\nTargeted org Order-PSOrg\n\nTargeted space TEST4\n\n\n\nAPI endpoint:   https://api.server02.pcf.com (API version: 2.131.0)\nUser:           [email protected]\nOrg:            Order-PSOrg\nSpace:          TEST4\n\u001B[32;1m$ $PRE_DEPLOY_CMD\u001B[0;m\n\"Deployment started\"\n\u001B[32;1m$ cf push $APP_NAME -p $TARGET -f $PCF_MF_FILE --no-start\u001B[0;m\nPushing f

I need to extract:

Targeted Org = *in this sample would be "Order-PSOrg"*

Targeted Space = *in this sample would be "TEST4"*

Api Endpoint = *in this sample would be "https://api.server02.pcf.com"*

Any suggestions?

Thanks,

Author:Marcel Goldhardt,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61529791/string-manipulation-regex
yy