O
O
Ord EO2020-12-04 12:20:32
ruby
Ord EO, 2020-12-04 12:20:32

How to split on the first occurring letter in Ruby?

How to split on the first occurring letter in Ruby?
For example, I have a string that contains the letter A 3 times.
string = 'sdfsdfsdadfgfdgfdgafdsfsd'
how can I split by letter number?
those.
what would work like this
sdfsdfsd dfgfdgfdgafdsfsd

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AVKor, 2020-12-04
@OrdeO

s = 'sdfsdfsdadfgfdgfdgafdsfsd'
first, rem = s[0...s.index('a')], s[s.index('a')+1..-1]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question