我有以下一行:
val CLMLINEFilterdDF = CLMLINE.filter(CLMLINEDF.CLM_LINE_ENCNTR_CD.isin("N","NA")
&& CLMLINEDF.CLM_LINE_STTS_CD.isin("PD","APRVD","PDZB","APRZB","VOID")
&& CLMLINEDF.HLTH_SRVC_TYPE_CD.notEqual( "ADA"))
我需要将其设置为以下格式:
val CLMLINEFilterdDF = CLMLINE.filter(CLMLINEDF("CLM_LINE_ENCNTR_CD").isin("N","NA")
&& CLMLINEDF("CLM_LINE_STTS_CD").isin("PD","APRVD","PDZB", "APRZB","VOID")
&& CLMLINEDF("HLTH_SRVC_TYPE_CD").notEqual( "ADA"))
如何在Unix脚本/命令中实现它?
我已经通过使用sed进行了尝试:
string="val CLMLINEFilterdDF =
CLMLINE.filter(CLMLINEDF.CLM_LINE_ENCNTR_CD.isin("N","NA")
&& CLMLINEDF.CLM_LINE_STTS_CD.isin("PD","APRVD","PDZB","APRZB","VOID")
&& CLMLINEDF.HLTH_SRVC_TYPE_CD.notEqual( "ADA"))"
echo $string | sed -r "s/CLMLINEDF\.(.*)CLMLINEDF\.(.*)CLMLINEDF\(.*)/CLMLINEDF("\1")("\2")("\2")/g"
但是它没有给出正确的结果
答案 0 :(得分:0)
$ sed -E 's/(CLMLINEDF)\.([^.]+)/\1("\2")/g' ip.txt
val CLMLINEFilterdDF = CLMLINE.filter(CLMLINEDF("CLM_LINE_ENCNTR_CD").isin("N","NA")
&& CLMLINEDF("CLM_LINE_STTS_CD").isin("PD","APRVD","PDZB","APRZB","VOID")
&& CLMLINEDF("HLTH_SRVC_TYPE_CD").notEqual( "ADA"))
(CLMLINEDF)\.([^.]+)
匹配CLMLINEDF
,后跟.
(元字符必须转义以进行字面匹配),后跟非.
字符
\1("\2")
根据需要重新安排g
替换所有此类匹配项