0

我的字符串是:

1BFM\",\"1BFR\",\"1BFZ\",\"1BKFH\",\"2BFE1\",\"2BFE2\",\"2BFH1A\",\"2BFH1B\",\"2BFH2A\",\"2BFH2B\",\"2BFM1\",\"2BFM2\",\"2BFP1\",\"2BFP2\",\"2BKIK1\",\"2BKIK2\",\"3BFA1\",\"3BFA2\",\"3BFA3\",\"B1SK\",\"B1MA\",\"BEJ1\",\"BEJ2\",\"BVE\",\"BVJK1\",\"BVJK2\",\"E1EI\",\"E1ME1\",\"E1ME2\",\"E1ME3\",\"E2EI\",\"E2ME1\",\"E2ME2\",\"E3EI\",\"E3ME1\",\"E3ME2\",\"E4EI\",\"E4ME1\",\"E4ME2\",\"FBF\",\"FBFK1A\",\"FBFK1B\",\"FBFK1C\",\"FBFK2A\",\"FBFK2B\",\"K2FR\",\"K3FR\",\"M1MV1\",\"M1MV2\",\"M1MV3\",\"M1SV\",\"M1VK1\",\"M1VK2\",\"M2MV1\",\"M2MV2\",\"M2MV3\",\"M2MV4A\",\"M2MV4B\",\"M2SV\",\"M2VK1\",\"M2VK2\",\"M3MV1\",\"M3MV2\",\"M3MV3\",\"M3SV\",\"M3VK1\",\"M3VK2\",\"M4MV1\",\"M4MV2\",\"M4MV3\",\"M4MV4\",\"M4SV\",\"R2PW\",\"R3PW\",\"R4PW\",\"SG8\",\"SG11A\",\"SG11B\",\"SG12A\",\"SG12B\",\"SG13\",\"TGI11\",\"TGI12\",\"TGI13\",\"TGME11\",\"TGT12\",\"TGT13\",\"TGTM11\",\"TGTM12\",\"TGTM13\",\"VAB\",\"Z2TI\",\"Z3TI\",\"Ab-FWG\",\"FA-CHSE\",\"Fo-CHSE\",\"HM-CHSE\",\"Rd-BSZ\",\"SCHB-FWG\",\"Sl-CHSE\",\"Zp-CHSE\",\"SET\",\"SLT\",\"Fußball-AG\",\"PD\

到目前为止,我的正则表达式看起来像这样:

(\".*?\")

我现在得到的是这样的:

1BFM\
1BFM\
1BFR\
1BFZ\
1BKFH\
2BFE1\
2BFE2\
2BFH1A\
2BFH1B\
2BFH2A\
2BFH2B\

那么我该怎么做才能使最后一个 \ 也被转义?

4

2 回答 2

1

您首先需要转义反斜杠。然后你需要转义两个反斜杠,对于 Java。我认为这应该有效:

(\\\\\".*?\\\\\")
于 2013-07-16T18:32:52.783 回答
0

您可以使用第二个反斜杠来转义反斜杠

(\\\".*?\")
于 2013-07-16T18:32:41.443 回答