Regular Expressions for Translators - Introduction
Thread poster: Shouguang Cao
Shouguang Cao
Shouguang Cao  Identity Verified
China
Local time: 07:42
English to Chinese
+ ...
Jul 21, 2017

In this series of articles, I will try to write a tutorial that makes sense to us, not to coding monkeys

What is Regular expression

We all use search and replace feature. Regular expressions are simply using wild cards to search and/or replace. I suppose you know how to replace “cat” with “dog”, but if you want to replace all three-letter words ending with “at” like “hat”, “mat”
... See more
In this series of articles, I will try to write a tutorial that makes sense to us, not to coding monkeys

What is Regular expression

We all use search and replace feature. Regular expressions are simply using wild cards to search and/or replace. I suppose you know how to replace “cat” with “dog”, but if you want to replace all three-letter words ending with “at” like “hat”, “mat”, “rat” with “dog”, you will need the wild card. With regular expressions, you can search for something that is not exact but follows certain patterns. For example, search for a 8 digit telephone number.

How can it be useful to translators

When you are frustrated by repetitive work, there is likely a simpler, automatic solution with regular expressions. Before I explain, let’s do an experiment just to admire the miracle.
First all use this link to download “notepad++”.
https://notepad-plus-plus.org/download/v7.4.2.html

Now launch notepad++, copy/paste the text into a blank text file in notepad++.

I love this game.:Me encanta este juego.
I love regular expressions.:Me encantan las expresiones regulares.
Regular expressions are amazing.:Las expresiones regulares son asombrosas.
They do wonderful things.:Hacen cosas maravillosas.
(Spanish translation provided by Google Translate)


Use “CTRL+H” to open the search/replace dialog, and tick “Regular Expressions” under search mode section. Press CTRL+HOME to put your cursor at the beginning of the file.

Task one: You want to delete all the English source text. (Search for “.*:” and leave Replace With empty)
Task two: Or you want to delete all the Spanish text. (Search for “:.*” and leave Replace With empty)
Task three: Or you want to switch the position of “source:target” to “target:source”. (Search for “(.*):(.*)” and replace with “\2:\1”

Isn’t this amazing? In this tutorial we will always learn by experiment, so please keep your notepad++ open! Regular expressions can be complicated, but it's really easy to know the basics and and start using them. I have translation work to do right now, and will continue to write next week. Let me know if you are interested! And have confidence in yourself and in me. I once wrote a guide to linux iptables for dummies and people say it's easy and clear !

http://dallascao.com/cn/iptables-tutorial-for-newbies/

(in Chinese though, but look the replies. They are all real.)





[Edited at 2017-07-21 15:18 GMT]
Collapse


 
Maxi Schwarz
Maxi Schwarz  Identity Verified
Local time: 18:42
German to English
+ ...
used how? Jul 21, 2017

I don't understand why I would search for "regular expressions" in the course of translating.

 
Soonthon LUPKITARO(Ph.D.)
Soonthon LUPKITARO(Ph.D.)  Identity Verified
Thailand
Local time: 06:42
English to Thai
+ ...
Great idea Jul 23, 2017

Shouguang Cao wrote:

Now launch notepad++, copy/paste the text into a blank text file in notepad++.

I love this game.:Me encanta este juego.
I love regular expressions.:Me encantan las expresiones regulares.
Regular expressions are amazing.:Las expresiones regulares son asombrosas.
They do wonderful things.:Hacen cosas maravillosas.
(Spanish translation provided by Google Translate)


Use “CTRL+H” to open the search/replace dialog, and tick “Regular Expressions” under search mode section. Press CTRL+HOME to put your cursor at the beginning of the file.

Task one: You want to delete all the English source text. (Search for “.*:” and leave Replace With empty)
Task two: Or you want to delete all the Spanish text. (Search for “:.*” and leave Replace With empty)
Task three: Or you want to switch the position of “source:target” to “target:source”. (Search for “(.*):(.*)” and replace with “\2:\1”


I rarely apply the Regular Expression function. But I promote extensive use of it to enhance our productivity.
I am going to be 65 years old. This is why I need to move proactively.

Dr. Soonthon Lupkitaro
Bangkok, Thailand


 
Shouguang Cao
Shouguang Cao  Identity Verified
China
Local time: 07:42
English to Chinese
+ ...
TOPIC STARTER
not difficult after all Jul 23, 2017

With just a little practise of the basic syntax, everyone can use regular expressions to do something.



Soonthon LUPKITARO(Ph.D.) wrote:

Shouguang Cao wrote:

Now launch notepad++, copy/paste the text into a blank text file in notepad++.

I love this game.:Me encanta este juego.
I love regular expressions.:Me encantan las expresiones regulares.
Regular expressions are amazing.:Las expresiones regulares son asombrosas.
They do wonderful things.:Hacen cosas maravillosas.
(Spanish translation provided by Google Translate)


Use “CTRL+H” to open the search/replace dialog, and tick “Regular Expressions” under search mode section. Press CTRL+HOME to put your cursor at the beginning of the file.

Task one: You want to delete all the English source text. (Search for “.*:” and leave Replace With empty)
Task two: Or you want to delete all the Spanish text. (Search for “:.*” and leave Replace With empty)
Task three: Or you want to switch the position of “source:target” to “target:source”. (Search for “(.*):(.*)” and replace with “\2:\1”


I rarely apply the Regular Expression function. But I promote extensive use of it to enhance our productivity.
I am going to be 65 years old. This is why I need to move proactively.

Dr. Soonthon Lupkitaro
Bangkok, Thailand


 


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


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

Regular Expressions for Translators - Introduction






Trados Studio 2022 Freelance
The leading translation software used by over 270,000 translators.

Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop and cloud solution, empowering you to work in the most efficient and cost-effective way.

More info »
CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »