Something in the dragon is capable of some languages, but can not see a 'snapshot' method of doing the following. I'm sure it's screaming out for a regex, but any solution I can come up with (regex groups and what's not) goes crazy very quickly.
So, I have a string with html-tags that I want to replace with actual HTML tags.
For example:
Hello, my name / beijen / b should be created:
Hello, my name & lt; B & gt; Jane & lt; / B & gt; is. It may also be underlined [i] talic and [u]:
/ iHello / i, my / uname / u / b / I / ujane / b / i / u should be created:
& lt; I & gt; Hello & lt; / I & gt ;, my & lt; U & gt; Name & lt; / U & gt; Is & lt; B & gt; & Lt; I & gt; & Lt; U & gt; Jane & lt; / B & gt; & Lt; / I & gt; & Lt; / U & gt; Obviously a straightforward strawels will not work because every other token will have to move forward as it moves forward.
For clarity, if there are tokens combo
PS: Before anyone gets excited, I know that such a thing should be Should have CSS, Blow, Blow, Blah, but I have not written the software, I just retreat its output!
Perhaps something like this can help:
import re def Text2html (text): "" "Convert text to HTML in a fixed format. Example: & gt; & gt; & gt; Text2html ('hello, my name is / bjen / b') Hello, my name & Lt; b & gt; Jane & lt; / b & gt; & Lt; i & gt; Hello & lt; / i & gt ;, My & lt; u & gt; Text 2 HTML ('/ IHollo / I, My / Anime / U / B / I / Usena / U / I / B ')' <<> Hello The name is & lt; / b> & lt; b & gt; & lt; i & gt; & lt; u & gt; ; Jane & lt; / u & gt; & lt; / i & gt; & lt; / b & gt; '"Elem.pop" (elem.index (match)) " "Return the format ([1] to re.sub (r '/.', To_tag, text) if __name__ =" __man__ ": import gatekeeper doctest.testmod ()
Comments
Post a Comment