I have this tex:
hello \o{test} how are you?
I want to convert it into:
hello <span>test</span> how are you?
how?
I have this tex:
hello \o{test} how are you?
I want to convert it into:
hello <span>test</span> how are you?
how?
You may use the following expression:
\\o\{([^}]+)}
\\o
Matches o
.\{
Matches {
.([^}]+)
Capturing group. Matches and captures anything other than a }
.}
Matches a }
.Replacing with:
<span>\1<\/span>
Regex demo here.
Sed implementation:
$ echo "hello \o{test} how are you?" | sed -r 's/\\o\{([^}]+)}/<span>\1<\/span>/g'
hello <span>test</span> how are you?
Php implementation:
<?php
$input_lines="hello \o{test} how are you?";
echo preg_replace("/\\\\o{([^}]+)}/", "<span>$1<\/span>", $input_lines);
Prints:
hello <span>test<\/span> how are you?