-2

How would I go about using regx to find all @ character in like this pattern @sonetext@ and get replace by {{ for start pattern and }} for end of pattern Here is an example:

@java.nio.charsets.StandardCharsets.UTF_8@ -- > {{java.nio.charsets.StandardCharsets.UTF_8}}

"@java.nio.charsets.StandardCharsets.UTF_8@ is the only.

To resolve this Destroy @MetaDexCharset@ - Destroy @JavaProperties.Io.ENCODING@* ->"

needs to look like

{{java.nio.charsets.StandardCharsets.UTF_8}} is the only.

To resolve this Destroy {{MetaDexCharset}} - Destroy {{JavaProperties.Io.ENCODING}}* ->
Shco
  • 9
  • 4

1 Answers1

-1

Is this what you want:

import re
text = '"@java.nio.charsets.StandardCharsets.UTF_8@ is the only.

To resolve this Destroy @MetaDexCharset@ - Destroy @JavaProperties.Io.ENCODING@* ->"'
text = re.sub(r'@(.*?)@', lambda x: '{{' + x.group(1) + '}}', text)
print(text)
costaparas
  • 4,683
  • 11
  • 14
  • 25