Python parser

I want to create a Python text parser. All texts in quotation marks should be found. This is quite simple in Passolo as a text parser, by setting " as the beginning and end connoisseur. But the problem is caused by escaped characters. If there is a quotation mark in the text, then write \". If you want to display a backslash \\. This is searched in paths and is often placed at the end of the string, directly before the closing quotation mark:
So I need a parser that can also parse the text.

print ("c:\\test\\" + "this is a \"test\"")

The parser should then return two texts:
c:\\test\\
and
this is a \"test\"

Any ideas?
Thanks Winfried
Parents
  • I can offer a much simpler solution that works without regular expressions. Simply use the quotes to look for strings and introduce a some mappings for the known escape sequences.

    Trados Studio screenshot showing the 'Strings  Comments' section with a search field and 'Mappings' section with two entries: M1 maps backslash double quote to double quote, M2 maps backslash single quote to single quote.

    This will also convert (and reconvert) the known escape sequences into the real characters for translators.

     Trados Studio screenshot displaying the 'Text' section with four lines of text demonstrating the use of quotes and escape sequences in a file path and sentences.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 10:32 AM (GMT 0) on 4 Mar 2024]
Reply
  • I can offer a much simpler solution that works without regular expressions. Simply use the quotes to look for strings and introduce a some mappings for the known escape sequences.

    Trados Studio screenshot showing the 'Strings  Comments' section with a search field and 'Mappings' section with two entries: M1 maps backslash double quote to double quote, M2 maps backslash single quote to single quote.

    This will also convert (and reconvert) the known escape sequences into the real characters for translators.

     Trados Studio screenshot displaying the 'Text' section with four lines of text demonstrating the use of quotes and escape sequences in a file path and sentences.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 10:32 AM (GMT 0) on 4 Mar 2024]
Children
No Data