07-18-2023, 09:03 PM
This is **Ruby 1.8.7** but should be same as for 1.9.x
I am trying to split a string for example:
a = "foo.bar.size.split('.').last"
# trying to split into ["foo", "bar","split('.')","last"]
Basically splitting it in commands it represents, I am trying to do it with Regexp but not sure how, idea was to use regexp
a.split(/[a-z\(\)](\.)[a-z\(\)]/)
Here trying to use group `(\.)` to split it with but this seems not to be good approach.
I am trying to split a string for example:
a = "foo.bar.size.split('.').last"
# trying to split into ["foo", "bar","split('.')","last"]
Basically splitting it in commands it represents, I am trying to do it with Regexp but not sure how, idea was to use regexp
a.split(/[a-z\(\)](\.)[a-z\(\)]/)
Here trying to use group `(\.)` to split it with but this seems not to be good approach.