O
O
Ord EO2020-03-27 22:54:21
ruby
Ord EO, 2020-03-27 22:54:21

How to replace text with regular expressions in Ruby?

There is a text line in which a preposition occurs, myI need to replace this preposition with in the whole sentence me, but if, for example, such a sequence of letters occurs in a word, then nothing needs to be changed inside the word, only an independent preposition, how can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-03-27
@OrdeO

str.gsub(/\bmy\b/, 'me')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question