开发者

Using regex to remove the first occurrence of white space and then replace the rest of the tabs with commas

开发者 https://www.devze.com 2023-01-02 01:59 出处:网络
Because I have lines like space space **da ta** tab tab **data** tab **data** tab tab tab tab **da ta**

Because I have lines like

space space **da ta** tab tab **data**
tab **data** tab tab tab tab **da ta**

I want the above to turn into

**da ta**,**data**
**data**,**da ta**

I need regex to remove all the white space before the first letter a开发者_如何学Cnd replace the rest with commas... but still ignoring the white space in between the letters in the data


s/^[ \t]+//;  # remove leading whitespace (just once)
s/[ \t]+/,/g; # replace all runs of spaces into commas globally
0

精彩评论

暂无评论...
验证码 换一张
取 消