问题描述:

e.g. i have string:

'Lorem @@[email protected]@ ad his scripta @@blandit [email protected]@, eum fastidii

accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus

suscipiantur, quo @@[email protected]@ ridens inciderint id. Quo mundi lobortis

reformidans eu, legimus @@senserit definiebas an [email protected]@.'

how to get an array with all ocurrences between '@@' and '@@'

网友答案:

You can do that with scan

string ='Lorem @@[email protected]@ ad his scripta @@blandit [email protected]@, eum fastidii accumsan euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo @@[email protected]@ ridens inciderint id. Quo mundi lobortis reformidans eu, legimus @@senserit definiebas an [email protected]@.'
p string.scan(/@@(.+?)@@/).flatten

gives

["ipsum", "blandit partiendo", "dicit", "senserit definiebas an eos"]
相关阅读:
Top