Does anyone know how to replace all ocurences '<\ d +' with a regular expression with '\ r \ n <\ d +', for example
"<20"
should be converted to
"\r\n<20"
but
"> HELLO < asassdsa"
do not touch
>>> import re >>> str = "<20" >>> output = re.sub(r'<(?=\d)', r'\r\n<', str) >>> output '\r\n<20'
import re def replace(value): return re.sub(r'(<\d)', r'\r\n\1', value)
Or using lookahead:
import re def replace(value): return re.sub(r'(?=<\d)', r'\r\n', value)
Source: https://habr.com/ru/post/1395397/More articles:scala The parser combinator did not back down as I thought ... - scalaSign out of your Twitter account using JTwitter? - androidWeird C # error replacing text string - stringDynamically embed a stylesheet in an iframe - jqueryWhat does the {} sign mean in this xaml code? - .netHow are 32-bit and 64-bit DLL files associated with the same C: \ system32 \ kernel32.DLL? - windowsStrong secure password recovery algorithm - securityHaving mySQL error, unknown column where clause - javalogging SQL expressions from HSQLDB - loggingReplacement Option for JSF Pages - jstlAll Articles