I am looking for a regular expression that will...
Thread poster: Michael Beijer

Michael Beijer  Identity Verified
United Kingdom
Local time: 07:57
Member (2009)
Dutch to English
+ ...
Jul 22, 2012

...find every line starting with a number of words enclosed in parentheses and followed by a number of words.

In the example below, I would like to find only the last line.



(word word)
(word word word word)

(word word)
(word word word)


(word)

(word word word word)

(word word word) word



Any suggestions are more than welcome!

Michael

PS: I'm not sure if this is relevant, but my text contains empty lines.

Incidentally, is there any program that can come up with the regular expression for me automatically if I feed it a sample input and output?



[Edited at 2012-07-22 02:27 GMT]


 

Rossana Triaca  Identity Verified
Uruguay
Local time: 03:57
Member (2002)
English to Spanish
I'm not sure I see the difficulty... Jul 22, 2012

Do you need to select the whole line? Or just find it?

If it's the later, a simple \)\s\w would work (finds the end parenthesis, a whitespace character -space, tab etc.- and an alphanumeric character).

But this seems too simple, perhaps you have a more complex format? If you need to select the whole line, \(.*\)\s\b.*\b works but its too tailored to your example... (finds anything between parenthesis followed by a whitespace followed by "whole" words).

Hope it helps!

[Edited at 2012-07-22 03:20 GMT]


 

Michael Beijer  Identity Verified
United Kingdom
Local time: 07:57
Member (2009)
Dutch to English
+ ...
TOPIC STARTER
Hello Rossana, Jul 22, 2012

Your second expression


\(.*\)\s\b.*\b


does the trick!

It's a little hard to explain, but the reason I need to do this is that I am working on a very large glossary in CSV format (with 5 columns: Dutch, Dutch Definition, English, second English, third English term), and I need to isolate only the lines that have something like '(word word word) word' on them, because these need to be fixed.

In a previous step, I used parentheses in a Find and Replace operation (it's a long story...), and in doing so inadvertently messed up sth that now needs to be fixed. I hope this makes at least SOME sense. Anyway, I had been scrolling down through the whole thing manually, trying to spot all of these lines visually, but with your regex I can now just find them all in one fell swoop and fix them, which will save me a LOT of time.

Thanks!

Michael


 

Rossana Triaca  Identity Verified
Uruguay
Local time: 03:57
Member (2002)
English to Spanish
Glad it helped! Jul 22, 2012

Remember that regex serches can preserve the match, so if you need to "move" that parenthesis within the line it can also be automatedicon_smile.gif

Best of lucks with that glossary!


 


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


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

I am looking for a regular expression that will...

Advanced search






SDL MultiTerm 2019
Guarantee a unified, consistent and high-quality translation with terminology software by the industry leaders.

SDL MultiTerm 2019 allows translators to create one central location to store and manage multilingual terminology, and with SDL MultiTerm Extract 2019 you can automatically create term lists from your existing documentation to save time.

More info »
SDL Trados Studio 2019 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2019 has evolved to bring translators a brand new experience. Designed with user experience at its core, Studio 2019 transforms how new users get up and running, helps experienced users make the most of the powerful features, ensures new

More info »



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