Regex to replace 'RIGHT SINGLE QUOTATION MARK' (U+2019)
Iniziatore argomento: Hans Lenting
Hans Lenting
Hans Lenting
Paesi Bassi
Membro (2006)
Da Tedesco a Olandese
Aug 10, 2023

Who can share a regular expression to replace the 'RIGHT SINGLE QUOTATION MARK' (U+2019) with a straight double quotation mark when it's not followed by an “s”?

Thank you in advance!

Hans


jonasollie7g
 
Samuel Murray
Samuel Murray  Identity Verified
Paesi Bassi
Local time: 13:55
Membro (2006)
Da Inglese a Afrikaans
+ ...
Which dialect? Aug 10, 2023

Hans Lenting wrote:
Who can share a regular expression...

In which program or in which dialect of regex?

E.g. in Microsoft Word, this works:
FIND: (’)([!s])
REPLACE: "\2

[Edited at 2023-08-10 08:55 GMT]


Hans Lenting
 
Hans Lenting
Hans Lenting
Paesi Bassi
Membro (2006)
Da Tedesco a Olandese
AVVIO ARGOMENTO
Good point Aug 10, 2023

Samuel Murray wrote:

Hans Lenting wrote:
Who can share a regular expression...

In which program or in which dialect of regex?


Oops, you're right again. I need it for Java (used by CafeTran Espresso).


 
Samuel Murray
Samuel Murray  Identity Verified
Paesi Bassi
Local time: 13:55
Membro (2006)
Da Inglese a Afrikaans
+ ...
Java Aug 10, 2023

Hans Lenting wrote:
Samuel Murray wrote:
Hans Lenting wrote:
Who can share a regular expression...

In which program or in which dialect of regex?

Oops, you're right again. I need it for Java (used by CafeTran Espresso).


According to this site:
https://www.freeformatter.com/java-regex-tester.html

This works:
FIND: (’)([^s])
REPLACE: "$2


 
Thomas T. Frost
Thomas T. Frost  Identity Verified
Portogallo
Local time: 12:55
Da Danese a Inglese
+ ...
Replace and replace back Aug 10, 2023

I think I would just replace all the ’ with " first and then replace all the "s to ’s.

 
Hans Lenting
Hans Lenting
Paesi Bassi
Membro (2006)
Da Tedesco a Olandese
AVVIO ARGOMENTO
Later Aug 10, 2023

Samuel Murray wrote:

According to this site:
https://www.freeformatter.com/java-regex-tester.html

This works:
FIND: (’)([^s])
REPLACE: "$2


Thank you, Samuel. I'll test it later. I had already used the method described by Thomas.


 
Tony M
Tony M
Francia
Local time: 13:55
Membro
Da Francese a Inglese
+ ...
SITE LOCALIZER
Word's own S-&-R Aug 10, 2023

Normally, you can just use Search & Replace all ' with ', and provided you have smart quotes turned on AND the correct language set, it will just do it automatically. It doesn't matter whether or not there is a trailing 's', all that matters is whether or not their is a leading space.

 
Thomas T. Frost
Thomas T. Frost  Identity Verified
Portogallo
Local time: 12:55
Da Danese a Inglese
+ ...
Hans doesn't want to change ’s Aug 10, 2023

Tony M wrote:

Normally, you can just use Search & Replace all ' with ', and provided you have smart quotes turned on AND the correct language set, it will just do it automatically. It doesn't matter whether or not there is a trailing 's', all that matters is whether or not their is a leading space.


Yes, but Hans doesn't want to change ’s to "s. What I understood he wanted was e.g.:

Change ‘Eric’s new house was falling apart’
to "Eric’s new house was falling apart"
rather than "Eric"s new house was falling apart".


 
Gjorgji Apostolovski
Gjorgji Apostolovski  Identity Verified
Macedonia (FYROM)
Local time: 13:55
Da Inglese a Macedone
+ ...
I was bored Dec 12, 2024

I know it's an old topic, but I was bored and here is my regex.

"(')(?!s|t)"



[Edited at 2024-12-12 14:08 GMT]


Hans Lenting
 
Hans Lenting
Hans Lenting
Paesi Bassi
Membro (2006)
Da Tedesco a Olandese
AVVIO ARGOMENTO
Thanks Dec 12, 2024

Thank you!

Image-000025


[Edited at 2024-12-12 15:21 GMT]


 
Gjorgji Apostolovski
Gjorgji Apostolovski  Identity Verified
Macedonia (FYROM)
Local time: 13:55
Da Inglese a Macedone
+ ...
np:) Dec 12, 2024

No problem, and you can also add |c for o'clock
but I'm afraid that this regex will fail when there will be words like 'sheets', 'communities', 'theaters', etc...

The solution will be to use two regex,

the first one:
Find=(')(?!s|t|c)
Replace="

the second one:
Find=( ')(?=s|t|c) (space before ' )
Replace= " (space before " )

And if you can make macro with these, you don't have to write them again.

... See more
No problem, and you can also add |c for o'clock
but I'm afraid that this regex will fail when there will be words like 'sheets', 'communities', 'theaters', etc...

The solution will be to use two regex,

the first one:
Find=(')(?!s|t|c)
Replace="

the second one:
Find=( ')(?=s|t|c) (space before ' )
Replace= " (space before " )

And if you can make macro with these, you don't have to write them again.



[Edited at 2024-12-12 17:48 GMT]

[Edited at 2024-12-12 18:05 GMT]
Collapse


 
Hans Lenting
Hans Lenting
Paesi Bassi
Membro (2006)
Da Tedesco a Olandese
AVVIO ARGOMENTO
Macro Dec 13, 2024

Gjorgji Apostolovski wrote:

And if you can make macro with these, you don't have to write them again.



The blue pane next to the Find and Replace window is popped up by a (Keyboard Maestro) macro whenever the window is opened. It contains the regular expressions I use most often.


Gjorgji Apostolovski
 


To report site rules violations or get help, contact a site moderator:

Moderatore(i) di questo Forum
Laureana Pavon[Call to this topic]

You can also contact site staff by submitting a support request »

Regex to replace 'RIGHT SINGLE QUOTATION MARK' (U+2019)






Protemos translation business management system
Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!

The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.

More info »
TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »