I have the following string
s = "hiack: 18 seqno: 37 cwnd: 20.000 ssthresh: 200 dupacks: 0"
I would like to use a regex to split that line up so it becomes
s = ['hiack: 18' 'seqno: 37' 'cwnd: 20.000' 'ssthresh: 200' 'dupacks: 0']
What regex pattern should I use to achive this?
Edit: I am using python incase that makes a difference
答案 0 :(得分:3)
% nodejs
> s = "hiack: 18 seqno: 37 cwnd: 20.000 ssthresh: 200 dupacks: 0"
'hiack: 18 seqno: 37 cwnd: 20.000 ssthresh: 200 dupacks: 0'
> s.split(/\b\s+\b/)
[ 'hiack: 18',
'seqno: 37',
'cwnd: 20.000',
'ssthresh: 200',
'dupacks: 0' ]
>
Even if you use anything else than JS, you can pick up the regex.
It works using \b
aka word boundaries