You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both leading and trailing punctuation need to be checked and extracted from around a word so that the string matching and replace can happen. Afterward, the punctuation will be combined again to preserve the structure.
def extract_punctuation(word)
leading_punctuation = word.match(/\A([^a-zA-Z]*)/)[1] rescue ''
trailing_punctuation = word.match(/[a-zA-Z]+([^a-zA-Z]*)\Z/)[1] rescue ''
word_length = word.length - leading_punctuation.length - trailing_punctuation.length
word = word[leading_punctuation.length, word_length]
return leading_punctuation, word, trailing_punctuation
end
The text was updated successfully, but these errors were encountered:
Both leading and trailing punctuation need to be checked and extracted from around a word so that the string matching and replace can happen. Afterward, the punctuation will be combined again to preserve the structure.
The text was updated successfully, but these errors were encountered: