Closed wansinby closed 1 year ago
Parsing HTML is very difficult (not recommended).
As you can see in the image below from https://regex101.com/, src
and width
attributes will throw an error, because have 3 letters before the equal sign (DEU is not analyzed because it respect the format of the language, neither label content, because is not parsed).
I don't think that there is a universal parse Regex for detecting all the cases of bad-formatting, and not colisioning with HTML syntax in comments. Maybe could be a Regex that won't throw an error in this case, but ¿will work in all HTML syntax?
If you want to use Regex for comment
and HTML code too, I suggest to split the string. The problem is
<img src="\\fileserver\Fotos\IMG-0007.jpg" width="600"/>
, create a locked label and concat with the others, so it will not throw an error. Or something like this (with the use of function STRSUBSTNO
):
EmailBodyTxt: label 'Dear Receiver,<br>Bodytext<br> %1<br>Best regards<br>MyName', Comment = 'DEU="Lieber Empfaenger,<br>Bodytext<br> %1<br>Mit freundlichen Gruessen<br>MyName"';
ImgTagTxt : label '<img src="\\fileserver\Fotos\IMG-0007.jpg" width="600"/>', Locked = true;
Dear Daniel, thank you for the analysis. I also think a Regex working for translation AND HTML doesn't exist, or is so complex you can't manage it. Your idea to separate the img-Tag in an extra label without translation is a great solution - and works fine. So this issue is solved with your hint and I will close it. Best regards, Wolfram
Dear Daniel, me again. I have a label with a body for an email. And ATC doesn't like the translation, the error is Translation error: DEU="Lieber Empfaenger. . ."
The AL-Code is:
EmailBodyTxt: label 'Dear Receiver,<br>Bodytext<br> <img src="\\fileserver\Fotos\IMG-0007.jpg" width="600"/><br>Best regards<br>MyName', Comment = 'DEU="Lieber Empfaenger,<br>Bodytext<br> <img src="\\fileserver\Fotos\IMG-0007.jpg" width="600"/><br>Mit freundlichen Gruessen<br>MyName"';
The reason is the "RegEx For Comment", I use
[A-Za-z][A-Za-z][A-Za-z]=(?:")
, but also\D\D\D=(?:")
brings the same error.If I write a space after the equal-sign of src and width (
scr= "\\..."
andwidth= "600"
), I get no error. But I think this is not correct HTML/XML. (If I remove "Regex for Comment" I also get no error.)Do you have an idea which Regex I could use to check the correct language but also to allow correct HTML?
Best regards, Wolfram