chogall
chogall

Reputation: 75

How to find single quotes and replace them by two single quotes in Notepad++?

I need to find single quotes in the text and replace them by two single quotes like this for instance :

l'arbre

=>

l''arbre

There are already a lot of places with two single quotes in the text, so I can't just use the find/replace function because it will pick up all those two single quotes together and they should stay so, without being modified.

Does anyone know how to do this ? I think I have to use regular expression but none that I've tried so far really work.

Thanks !

Upvotes: 2

Views: 6103

Answers (4)

GriM
GriM

Reputation: 3

Find what: ([^'])(['])([^'])

Replace with: \1''\3

This replaces only single quotes with double and leaves the double that are already there unchanged

Upvotes: 0

berty
berty

Reputation: 2206

Press ctrl + h and in normal mode (no regex) :

1) replace ' by ''

2) replace '''' by ''

Upvotes: 1

Ricardo Lohmann
Ricardo Lohmann

Reputation: 26320

Press ctrl + F, go to the second tab(or ctrl + h).

  • Put ([a-zA-Z0-9]+)\'([a-zA-Z0-9]+) on the first input.
  • Put \1"\2 on the second input.
  • On search type, select regular expression.
  • Press replace all.

Matches: text'text, 09text09'09text09, text'09text09, 09text09'text

Doesn't match: text', 'text, '

Upvotes: 1

Scott Evernden
Scott Evernden

Reputation: 39986

find what: '
replace with: ''

works for me. no regex required

Upvotes: 0

Related Questions