Artificial intelligent assistant

Extract substring using regular expression on a Unix file I have file with below contents . /ABC/RTE/AD_900_VOP_123/OPP /ABC/RTE/TRE/AD_900_VOP_145/BBB /ABC/RTE/AN_900_VFP_124/FBF /ABC/RTE/HD_900_FOP_153/WEW /ABD/RDV/AD_900_VOP_123/OPP /ABC/RTE/WD_900_VOP_123/GRR/TRD /ABC/RTE/RTD/AR_900_VOP_443/SDD How can I use regular expression on this file such that I get the output such as AD_900_VOP_123 AD_900_VOP_145 AN_900_VFP_124 HD_900_FOP_153 AD_900_VOP_123 WD_900_VOP_123 AR_900_VOP_443

Gnu grep


grep -oE '[[:alpha:]]+_[[:digit:]]+_[[:alpha:]]+_[[:digit:]]+'


Use the perl-regex flag and look-behind and look-ahead assertions to guarantee that the match is surrounded by `/`


grep -oP '(?<=/)[[:alpha:]]+_[[:digit:]]+_[[:alpha:]]+_[[:digit:]]+(?=/)'

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy e0add18e1a5b58c3308897515a3ef77f