Using find&replace to change commas to periods
Thread poster: Emma Goldsmith

Emma Goldsmith  Identity Verified
Spain
Local time: 10:41
Member (2010)
Spanish to English
Apr 30, 2011

I can't manage to change commas to periods in numbers using Find&Replace in Studio 2009.

I'm translating a badly formatted restaurant menu with lots of tags so I thought it would be quickest to copy all source to target. Each segment starts with a number in a special font, followed by the item, a row of periods and ending with the price.
e.g.
23 Salad with lettuce, tomato and cucumber ........................ 5,80

So I want to replace the comma in the price with a period. Using Find&Replace and enabling widlcards / regular expressions, I've tried:

Find: ([0-9]),([0-9])
Replace with: \1.\2

and also
Find: \d\,\d+
Replace with: \d\.\d+

Both replace the comma with a period but the numbers get replaced with the symbols.

Can anyone explain what I am doing wrong?
Thanks in advance.


Direct link Reply with quote
 

István Hirsch  Identity Verified
Local time: 10:41
English to Hungarian
Studio regex Apr 30, 2011

You cannot use regex this way in Studio, because it cannot remember in Replace step what it had found in Find step (\1 and \2 for example).
Use this lookahead instead:
Find: ,(?=[0-9])
Replace with: .
This will replace every comma which is followed by a number with a period.


Direct link Reply with quote
 

Tomoyuki Kono  Identity Verified
United Kingdom
Local time: 09:41
Member (2010)
English to Japanese
+ ...
use a text editor? Apr 30, 2011

Isn't SDLXLIFF just an XML-based text file? If that's the case, can't you just open the file in a text editor and run your regex search & replace on it?

The only disadvantage is that you will then have to update your TM.


Direct link Reply with quote
 

Eileen Cartoon  Identity Verified
Local time: 10:41
Italian to English
Studio should do this automatically Apr 30, 2011

If you have set the languages and IF the serios of dots does not touch on the number (....5,60 as opposed to .... 5,60) Studio should read this as a number and the number should be underlined in blue on the source column. If it is just hit control+comma and select the number that pops up. It should then be inserted with the applicable decimal points in place.
Eileen


Direct link Reply with quote
 

Emma Goldsmith  Identity Verified
Spain
Local time: 10:41
Member (2010)
Spanish to English
TOPIC STARTER
Solved! Apr 30, 2011

Thank you everyone for your ideas
@ István: I followed your advice and it worked perfectly. Thanks!
@ Tomoyuki: Yes, I could certainly do this afterwards in Word, but I wanted to learn how to do it in Studio.
@ Eileen: Yes, I could use control+comma for each number as I have got "recognize numbers" enabled in fields and settings in the TM, but in this particular file I wanted to use Find&Replace as it was the quickest solution.

I was interested to learn about the "look ahead" wildcard. I must try to remember it in the future, so thanks again, István.


Direct link Reply with quote
 

Edward Potter  Identity Verified
Spain
Local time: 10:41
Member (2003)
Spanish to English
+ ...
How I switch commas and decimal points in Word tables May 2, 2011

This is they way I switch these little guys in MS-Word tables with only numbers:

1) Select the entire table
2) Replace all . with *
3) Replace all , with .
4) Replace all * with ,

Done.


Direct link Reply with quote
 
FarkasAndras
Local time: 10:41
English to Hungarian
+ ...
Regex intricacies May 2, 2011

Edward Potter wrote:

This is they way I switch these little guys in MS-Word tables with only numbers:

1) Select the entire table
2) Replace all . with *
3) Replace all , with .
4) Replace all * with ,

Done.

That's way too crude for what the OP is trying to do. It will replace all . with , while the OP only wants to replace periods (commas, in fact, but that's beside the point) in numbers, which is the point of this thread. The lookahead is the right solution here.

As usual, István came through with solid regex advice.
I was still holding out some hope that Studio has the insert match feature that the OP was trying to use. I even started a thread to ask about this specifically, but Trados support failed to provide any information. I have to assume that István is right and Studio doesn't have this feature. Quite a big and baffling oversight considering the regex engine has advanced things like lookahead.

[Edited at 2011-05-02 14:16 GMT]


Direct link Reply with quote
 

Wolf Kux  Identity Verified
Brazil
Local time: 07:41
Member (2006)
German to Portuguese
+ ...
This has a drawback... May 2, 2011

Edward Potter wrote:

This is they way I switch these little guys in MS-Word tables with only numbers:

1) Select the entire table
2) Replace all . with *
3) Replace all , with .
4) Replace all * with ,

Done.



It is interesting, but a small drawback when word finds other asterisks, running step 4. So I suggest to use instead of "*" an expression that is not anywhere on this files, e.g. "@#$%" or alike.

Or, before starting step 2, try to replace "*" with ""*". Yes, replace by the same. This gives you a count on how many asterisks are on your file, before you do this change.

[Editada em 2011-05-02 19:09 GMT]


Direct link Reply with quote
 

Emma Goldsmith  Identity Verified
Spain
Local time: 10:41
Member (2010)
Spanish to English
TOPIC STARTER
To the regex experts May 2, 2011

Thanks Edward and Wolf, but I am trying to go one step further here and use Regex.

To our resident regex experts - István and FarkasAndras: Have either of you thought of offering a webinar on Regex? I would be really interested and I'm sure other people would be too.

I hadn't seen your previous thread, FarkasAndras, and it was just what I was trying to do. The lookahead works brilliantly, but I agree that Studio should certainly do the "insert match" as well.


Direct link Reply with quote
 
FarkasAndras
Local time: 10:41
English to Hungarian
+ ...
regex webinar May 5, 2011

Emma Goldsmith wrote:

To our resident regex experts - István and FarkasAndras: Have either of you thought of offering a webinar on Regex? I would be really interested and I'm sure other people would be too.


I'm not the teacher-y sort of guy and I'm not too keen on getting involved in "proz stuff", so, while a crash course on regex (and MS Word wildcards) would surely benefit most members, I'm not going to be the one holding it. I usually follow the forum, though, and if interesting regex questions come up, I'll try to answer them.

[Edited at 2011-05-05 21:45 GMT]


Direct link Reply with quote
 
FarkasAndras
Local time: 10:41
English to Hungarian
+ ...
Risky Jul 14, 2011

Tomoyuki Kono wrote:

Isn't SDLXLIFF just an XML-based text file? If that's the case, can't you just open the file in a text editor and run your regex search & replace on it?

The only disadvantage is that you will then have to update your TM.


One could do this, but there is a risk of some parts of the XML markup matching your expression. Then you could accidentally alter or even corrupt the file. It's safer and more convenient to do this in Studio or some other tool that parses the XML first.


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 10:41
English
Just an update Sep 14, 2012

Hi,

This thread was referred to me earlier today so I thought I'd share an update. Regex replacement will be possible in the update to SP2 due next week : http://goo.gl/aIhkR

Regards

Paul


Direct link Reply with quote
 
Mariusz Lasota
Local time: 10:41
English to Polish
Regex find and replace works fine Apr 23, 2013


I can't manage to change commas to periods in numbers using Find&Replace in Studio 2009.

I'm translating a badly formatted restaurant menu with lots of tags so I thought it would be quickest to copy all source to target. Each segment starts with a number in a special font, followed by the item, a row of periods and ending with the price.
e.g.
23 Salad with lettuce, tomato and cucumber ........................ 5,80

So I want to replace the comma in the price with a period. Using Find&Replace and enabling widlcards / regular expressions, I've tried:

Find: ([0-9]),([0-9])
Replace with: \1.\2

and also
Find: \d\,\d+
Replace with: \d\.\d+

Both replace the comma with a period but the numbers get replaced with the symbols.

Can anyone explain what I am doing wrong?
Thanks in advance.


---------
To do this in SDL Studio use this:

Find: (\d)\,(\d)
Replace with: $1.$2

...and you're done

Just remember to tick the "Use regular expressions" option in the find and replace window.


Direct link Reply with quote
 
hindi_linguist
India
Local time: 15:11
English to Hindi
+ ...
Great! Apr 23, 2013

Edward Potter wrote:

This is they way I switch these little guys in MS-Word tables with only numbers:

1) Select the entire table
2) Replace all . with *
3) Replace all , with .
4) Replace all * with ,

Done.


This is very helpful.


Direct link Reply with quote
 


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


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

Using find&replace to change commas to periods

Advanced search







Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »
BaccS – Business Accounting Software
Modern desktop project management for freelance translators

BaccS makes it easy for translators to manage their projects, schedule tasks, create invoices, and view highly customizable reports. User-friendly, ProZ.com integration, community-driven development – a few reasons BaccS is trusted by translators!

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search