Convert RegexBuddy libraries to the memoQ Regex Assistant!
Interoperability with a popular solutions library tool and syntax analyzer
Recently, I posted an article on the Translation Tribulations Substack (and finally remembered to cross-post it on this Substack for convenience) in which I described how to take exported collections of regexes from the memoQ Regex Assistant and make use of them in the popular Regex Buddy tool.
Now, for the sake of symmetry, I’ll show you how to go the other way, that is to take solution libraries from RegexBuddy and bring them into memoQ’s library of solutions in the Regex Assistant. And I’ll cross-post this article to the Translation Tribulations Substack (just web, skipping the e-mail like I did with the other cross-post, because I do my best not to spam y’all.)
But you may ask, “Why bother with all this?”
With respect to RegexBuddy, I know a number of technically gifted folk in the language services sector who have used this tool for a very long time, and they have probably accumulated a significant collection of solutions to common problems encountered in translation and localization projects and saved a number of these in their RegexBuddy libraries. Some of them I know also use memoQ, but even those that don’t work with people who do, and this article is intended to help them share if they want to. There are also quite a number of people outside the language services sector who use this tool, and if they have solutions of interest to wordworkers, the XSLT process described here will facilitate the exchange of technical solutions with them.
memoQ users who avail themselves of the Regex Assistant, which is included in the memoQ installation, may also benefit from the use of RegexBuddy because of its features like color highlighting of expression elements for better legibility, syntax analysis and debugging tools, translation assistance to other dialects of regex (which might be helpful if using your regex solutions in another regex-savvy translation or text editing environment) and more. But if you send a complex expression that doesn’t work the way to want to RegexBuddy for troubleshooting and fixing, you’ll want to bring it back perhaps, and just do a simple import to install the fixed solution in your Regex Assistant library, right?
The RegexBuddy app also has a nice way of storing test data with the solution record, and I’ve configured the conversion script to include this test data at the end of the Description field in a memoQ Regex Assistant record. I find it a PITA to juggle dozens of test data files all the time, so I expect this may reduce my headaches. Or butt aches as it were.
I’m new to RegexBuddy and am still on the free trial, but as it costs slightly less than €40 and I’ve found it helpful, I’ll cough up the cash and become a registered user sometime in the next week. Then I’ll publish some videos and other tutorials which I think may help some of you. I don’t find the user interface nearly as clean and navigable as that of the Regex Assistant, not just because it does a lot more, but also because it’s kind of a thing for propeller heads, and their idea of user-friendly may differ from yours and mine. But it’s worth a little time to orient oneself there, and I’ll do what I can to help with that in the planned tutorials.
The conversion script was interesting to write. I’ve never had to parse strings with XSL before, just took all the text at any given node in an XML file, but the somewhat unfortunate way in which RegexBuddy conflates the “name” of a saved regex and its description in the same field called for a little string splitting, which was accomplished with a regular expression. I’ve been monkeying around with XSL 1.0 for about 25 years now since the days when I used to write software user instructions in German in DocBook XML, and until yesterday I was unaware of the enormous changes that occurred in XSL 2.0 and 3.0, which include the options of using regex. The syntax still feels a bit weird for me, so I’ll probably be saving some of it in RegexBuddy to help myself out.
The XSL 2.0 script for the conversion is below. Copy and paste it into a text file, save it and name it to include the extension *.xsl
; you can use it with the free XML Notepad or a free XSL 2.0 or 3.0 test page to do your conversions of the RegexBuddy *.rbl
libraries. First a screenshot with nice colors, then as text you can copy and paste.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!--Converts RegexBuddy to memoQ Regex Assistant library format-->
<xsl:template match="/">
<RegexLibrary xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Items>
<xsl:for-each select="//libraryfile/action">
<Item>
<xsl:variable name="nameValue" select="description"/>
<xsl:analyze-string select="$nameValue" regex="(.+?)(
|
)">
<xsl:matching-substring>
<Name><xsl:value-of select="regex-group(1)"/></Name>
</xsl:matching-substring>
</xsl:analyze-string>
<FindRegex><xsl:value-of select="regex"/></FindRegex>
<ReplaceRegex><xsl:value-of select="replace"/></ReplaceRegex>
<Description><xsl:value-of select="description"/><xsl:text>
</xsl:text>
<xsl:value-of select="teststring"/></Description>
</Item>
</xsl:for-each>
</Items>
</RegexLibrary>
</xsl:template>
</xsl:stylesheet>