This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello. I am trying to add a new line after the punctuation on run-in text with no spaces which looks kinda like this:
"Hello,thisis,asample.Iamtrying,toworkwiththis."
The code I am writing uses re.sub() as follows:
"new_string = re.sub(",", ",/n", string)"
This code works and adds a new line after every comma like you would expect. However when I try it with a period it doesn't work. It works with every other character except the period. Instead it just prints a line of periods. Is the period a special character for re.sub()? If it is (or isn't) how do I get around it? Thanks for taking the time to read this.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...