简体   繁体   中英

Notepad++: Find Using Regular Expression and Replacing with Extra Comma

I have a comma delimited file that I want to add another comma after the ID: number, but before the street address, such as:

Adam,ID:1,200,N,Sway,Rd.,Hometown,IN,46111,Website:,
Allison,ID:2,201,N,Sway,Rd.,Hometown,IN,46111,Website:,
Bob,ID:31,202,N,Sway,Rd.,Hometown,IN,46111,Website:,
Carl,ID:49,203,N,Sway,Rd.,Hometown,IN,46111,Website:,

I am using the below, to find the comma delimiter before the address, in the Replace window "Find what:" field.

,ID:[0-9]{1,2},

I am failing to understand what regular expression to use in the Replace window "Replace with:" field, so that I can achieve the below output for the comma delimited file.

Adam,ID:1,,200,N,Sway,Rd.,,Hometown,IN,46111,Website:,
Allison,ID:2,,201,N,Sway,Rd.,,Hometown,IN,46111,Website:,
Bob,ID:31,,202,N,Sway,Rd.,,Hometown,IN,46111,Website:,
Carl,ID:49,,203,N,Sway,Rd.,,Hometown,IN,46111,Website:,

The end output is to eventually remove all of the delimiters from the street address by using the double comma delimiters as the search context begin and end markers.

There is no need adding anything to your regex.

To access the whole match in the replacement string, you may use one of the following value:

$&
$MATCH
${^MATCH}
$0
${0}

Add a , after one of these, and use in the Replace With field.

See Notepad++: Substitutions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM