我有包含以下字符串的文本文件:
coordsys = "Z:/SatData/Satimages/Project/Mtsat/mtsat-2r/nrl/NW-Pacific/Geo-Color/Project/201108170432_DAY1.jp2"
coordsys = "Z:/SatData/Satimages/Project/Mtsat/mtsat-2r/nrl/NE-Pacific/Geo-Color/Project/201208170432_NGT1.jp2"
coordsys = "Z:/SatData/Satimages/Project/kalpana/images/Geo-Color/Project/201108170432_DAY1.jp2"
img = ".jp2"
我只需要在以“coordsys”开头的字符串中将扩展名从 jp2 更改为 img,而不是其他任何字符串。例如 img = ".jp2" 应保持 img = ".jp2",但所有其他字符串应变为:
coordsys = "Z:/SatData/Satimages/Project/Mtsat/mtsat-2r/nrl/NW-Pacific/Geo-Color/Project/201108170432_DAY1.img"
coordsys = "Z:/SatData/Satimages/Project/Mtsat/mtsat-2r/nrl/NE-Pacific/Geo-Color/Project/201208170432_NGT1.img"
coordsys = "Z:/SatData/Satimages/Project/kalpana/images/Geo-Color/Project/201108170432_DAY1.img"
我怎么能用正则表达式做到这一点?