我有一个看起来像这样的json字符串:
{
operations: [
validateAddressAndBRClassification, vintageValidateAddressAndGeo, deleteShareInformation, validateCountry, validatePostcode, pageThroughAddress, getFromRelationships, getToRelationships, getUnresolvedAddresses, validateCity, getVisits, getOperationalAddress, getGeo, looseAddressSearch, getServiceInformation, getAddress, getInternalProp, validateAddress, disputeBR, validateAddressAndGeo, supportedCountries, internalMx, getBRProfileHistory, databaseStatus, getBRProfile, addressLookup, getDataSourceMetaInformation, getBRDisputeHistory, validateStateProv, getGeopoliticalElementList, validatePostal, postalLookup, signalDataSourceChange, setInternalProp, getShareInformation, addVisit, addressSearch, getRelatedAddresses, ping, showOperations
]
}
我需要添加双引号"到每个单词的开头和结尾。这个正则表达式会是什么?
所以我需要它看起来像这样:
{
"operations": [
"validateAddressAndBRClassification", "vintageValidateAddressAndGeo", "deleteShareInformation", "etc"
}
答案 0 :(得分:1)
我不确定您使用的是哪种编程语言,但在JavaScript中,您可以使用以下行来实现它:
string = string.replace(/(\w+)/g, "\"$1\"");