I need to find translation keys inside html text:
e.g. "<p class='m-0 p-0 mx-2 d-inline-block'>{{'MEDIA_SERVER_URL' | translate}}: </p>";
I need to find MEDIA_SERVER_URL in this. conditions like that
- Should be enclosed by either single quote or Double quotes.
- Should have all CAPS
- Should be inside {{}} pair braces.
ChatGpt give answer like var pattern = /{{?'([^']+?)'[\s\S]*?[A-Z_]+}?/g;, that’s not working.
Can anyone please help me. I don’t have that expertise in regex to solve this myself.
Thanks
>Solution :
The pattern is /{{\s*(['"])([_A-Z]+)\1\s*\|\s*translate\s*}}/g and the keys you’re looking for should be in group#2.
You may go to https://regexr.com/7tnih to have a try.