How to hide JavaScript code ${}

I have an Excel document for translation, where are parts of JavaScript.

Example - "Dear ${task.userCaption},Please approve Leave request registered by${workflow.originatorCaption}:Employee: ${document.HPEmployeeAssignment.HPEmployeeRoleAssignment.HPPersonGeneric.name}."

How could I add embedded content for those parts which start with ${ and end with }, so that Trados understands it as a Tag?

Kind regards,

Kaspars Rutkis

Parents Reply
  • Perhaps this will also help:

    \${[^}]*?}

    Breaking it down:

    \$
    The dollar symbol has a special meaning in regex so if you just put a $ to match the $ in the text it would only cause the matching to start from the end of the line.  So you have to escape it which you do with the backslash.

    {
    This simply matches the first curly bracket, {

    [^}]
    Putting a string of characters inside square brackets will match any of the characters listed.  Putting a carat symbol first, so this symbol ^, will negate that match.  So [^}] matches anything apart from the closing curly bracket, }.

    *
    The * operator will cause the previous match to be repeated zero or unlimited times, and keep searching until it cannot find whatever comes next.  It's what's known as a greedy operator.

    ?
    In this context, after the *, the question mark will cause the expression to be lazy instead of greedy.  This just means it won't inadvertently capture more than it should.  I tend to use this as a matter of course to be a bit more concise, but it may not be needed in your case at all.  No harm done but most people who like to tinker with regex like to use as few characters as possible... sort of a challenge for fun.

    }
    This just matches the final closing curly bracket in the pattern you are matching.

    Hope that helps a bit.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

Children