Have a below output and wanted to remove the white space and line breaks.
\n', ' var [3:0] apple [1:0];\n', ' int mango;\n', ' float banana [5:0];\n', ' int lichi;\n', '
I tried both the below code but its not working. Any comments/corrections ?
print str(str(re.sub('[^A-Za-z0-9[:]]+[\r\n]+', ' ', str(match_group_t[i]))))
print re.sub(r"(?<=[a-z])\r?\n"," ", match_group_t[i])
Drop in your comments for any correction !
Expected Output is : Only
var [3:0] apple [1:0], int mango, float banana [5:0], int lichi. So that I can store type and name separately in an array and use it later. Like
variable data in an array: [apple, var, lelem, [3:0], rleme, [1:0]]
string.replace(" ", "")andstring.replace("\n", "")var apple?), but I don't see why a variant ofprint(re.sub("\s{2,}", "", s))wouldn't suffice offhand.>>> a = "\n asifjdiasd fjj jads \n">>> a.replace("\n", "")' asifjdiasd fjj jads '