Artificial intelligent assistant

REGEX Find string in path and exclude part of string Hopefully this is an easy one. I am using the `REG_EXTRACT` in Informatica to extract a file name from a variable. It uses regex to identify what to extract. Here is my example. This is my file name with file path as it comes into powercenter. FILENAME=/test_files/infa_test/nippy/SrcFiles/JUNK/JUNK_OPS_SPINK_PAE_01-01-01-01-01-99.csv REG_EXTRACT($FILENAME,'^\/(.+\/)*(.+)$',2). The produces `JUNK_OPS_SPINK_PAE_01-01-01-01-01-99.csv`. I'm having a hard time writing the regex argument to only extract the file_name after JUNK/ but before _SPINK like 'JUNK_OPS'. The underscores vary from file to file but '_SPINK' will always appear after what I need to extract. Any help would be great.

Something like this maybe:


^.*\/(.*)_SPINK.*$


Unfortunately, I don't have access to Informatica to test it, but `sed` agrees:


echo '/test_files/infa_test/nippy/SrcFiles/JUNK/JUNK_OPS_SPINK_PAE_01-01-01-01-01-99.csv' |
sed -E 's/^.*\/(.*)_SPINK.*$/\1/'


This produces `JUNK_OPS`.

Depending on how `REG_EXTRACT` works, it may be shortened to


\/([^/]*)_SPINK

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 86328d7e3532a3deeab7b9f8077c02da