Regex for quotation marks.


I would like to add some regex into my QA checker to search for quotations mark such as

And those alternatives with spaces too.

I do not know if someone can help me with this but even after a some research, it does not seem to work. Any suggestion on Regex to search these items in a sdlxliff file?

Thank you very much for you help!

  • Hi Marine,

    Probably best if you provide an example of the source and target so the appropriate QA check could be suggested.


  • All these in one file? Well, that can be a bit complicated, as the German ones do NOT require spaces, while the French ones do.
    For example to run a Sarch & Replace for straight quotes to German ones run these two operations:
    Search: (")([a-z0-9])
    Replace: „$2
    Search: ([a-z0-9]\b)(")
    Replace: $1“

    In the QA checker I have added the straight quotes directly as forbidden elements. This finds all remaining, for example such between tags or similar.
  • Anonymous
    0 Anonymous over 5 years ago in reply to Jerzy Czopik
    Thank you so much for your reply.

    What I am actually looking for is a search in the target only, no matter how it is in the source (for QA purposes): I only want to use the following quotation marks: «» without spaces (example: «XXXX»).

    I thus want to search for all other types of quotation marks in my text :
    - "xxxxxxxxx" (without spaces)
    - " xxxxxxxxx " (with spaces)
    - « xxxx » (with spaces)

    I am sorry but I am really not familiar with Regex and I tried to learn a bit. Other types of regex were easier to write but I could not figure out how to write them.

    Since you talk about "Search and Replace", do you know if there is a way to do a find and replace of various things at the same time. For example, clicking on button to replace the quotation marks, the double spaces and so one. If I am right, QA Checker only informs you of a mistake but does not correct it automatically.

    Once again, thank you so much for your help.
  • Anonymous
    0 Anonymous over 5 years ago in reply to Paul

    Thank you for your answer. I provided a more detailed explanation in my reply beneath.
    Kind regards,

  • Hi Marine,

    This should do it:

    - Go to Verification - QA Settings - Regular Expressions

    - Give your new rule a name under Description

    - Leave the RegEx source empty

    - In the RegEx target, enter the following:

    "|" | "|« | »

    (Note there are spaces after or before the quotes from the second one on)

    - In the Condition dropdown list, choose Report if target matches (target check only)

    - In the Action dropdown button, select Add Item. Click OK.

    And you're right, the above will tell you when one of the wrong forms is present but it won't replace them. You would need to run a separate find and replace operation for that.
  • Hi Marine,

    Maybe these three rules would do you?

    - "xxxxxxxxx" (without spaces)


    - " xxxxxxxxx " (with spaces)


    - « xxxx » (with spaces)


    Then make sure you  use this option:

    So this will find all cases where these conditions exist.  It won't find the cases where they don't exist because this would be a little tricky and probably find every segment in the file where quotes are not being used... not really what you want  You have to look at cases where quotes are used and think about how they are misused and then write the rules to find the misuse.  If they are matching the source in some way it's easier because you have something to compare to.

    Does this help?


  • Hi Nora,

    I like that you try to get these rules into one expression... but worth noting a few things to be careful with.

    1. You won't be able to make sure the correct quote is being used
    2. You won't be able to check for one space only... you could have 100 spaces and it will pick up the same result
    3. You could leave a quote out and it will report the same message (although maybe this is useful)

    I like the concept "economy of accuracy" but sometimes it pays to be a little more specific.



  • In fact I need to correct one as it's wrong.  This is better like this otherwise you can't have more than one word between the quotes:

    - "xxxxxxxxx" (without spaces)




  • Anonymous
    0 Anonymous over 5 years ago in reply to Paul
    Thank you so much Paul and Nora for both your answer.

    I tested both solutions and Paul's solution is indeed more accurate. I have been working on this for awhile now and it is now working as I wanted it.


    Kind regards,
  • Thanks, Paul, very informative, still learning about RegEx! : )
  • I like your learnings Nora... I work the same way and try anything I see people asking!
  • Now you take this for the search:
    and run the replace with:
    to replace the straight quotes with the ones you wanted

    You can also enter for search:
    (("|„|”|« ))(\S.*?\S)(("|“|”| »))
    to replace all kind of quotes with the quotes you wanna have.