+2 votes
in General by (11.2k points)

I have a file with more than 1000 records. Some of the records are as follows:

ABCB9
ABCC8
ABO
ADCY5

I want to add single quote at the beginning and end of each of these records.

'ABCB9'
'ABCC8'
'ABO'
'ADCY5'

What is the simplest and easiest way to get this desired result?

1 Answer

0 votes
by (17k points)
edited by

Here are steps to add single quote at the beginning and end of each of the records in your file:

Using Notepad++

1. Open your text file in Notepad++ editor.

2. Press Crtl+H. It will open the 'Replace' window, select 'Regular expression' in 'search mode' on that window.

Notepad++ editor

3. Type ^ (beginning of the line) in 'Find What' and ' (single quote) in 'Replace with'. Then click on 'Replace All' to add a single quote at the beginning of each record.

4. Type $ (end of the line) in 'Find What' and ' (single quote) in 'Replace with'. Then click on 'Replace All' to add a single quote at the end of each record.

Using Geany

1. Open your text file in Geany editor.

2. Press Crtl+H. It will open the 'Replace' window, select 'Use regular expressions'.

Geany editor

3. Type ^ (beginning of the line) in 'Search for' and ' (single quote) in 'Replace with'. Then click on 'Replace All' to add a single quote at the beginning of each record.

4. Type $ (end of the line) in 'Search for' and ' (single quote) in 'Replace with'. Then click on 'Replace All' to add a single quote at the end of each record.

...