regex - Replace nth occurence of a character by another -


i hope isn't duplicated, didn't find answer , need regexp wizards.

i have string , replace second space found in \n, don't know how use indices (this way) in regular expression :

for example :

# have : "a b c d e f" # want : > "a b/nc d e f" 

also know how can "repeat" replacement: each 2 occurences of space replace \n. example :

"a b c d e f" > "a b\nc d\ne f" 

(\\s+\\s+\\s+)\\s+ 

you can use , replace \1\n or $1\n.see demo.

https://regex101.com/r/yg7zb9/29


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -