Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Regular Expression) Letter Count
#3
The gsub! method just replaces all instances of .!? with .\005[4] !\005[4] ?\005[4] which is my control code for "stop text rendering for a bit (4 frames)" it works exactly like all the other special codes for gold, hero name, etc. So printed_length in this case would always return 7.

I need to come up with a different solution, possibly capturing the sentence into $2 and using that as the frames to wait.

Edit: 10 minutes of playing around on http://rubular.com/ got me to /(.+?)([?.!][^\n\z"])/

so
Code:
@text.gsub!(/(.+?)([?.!][^\n\z"])/) { "#{$1}#{$2}\005[#{$1.length}]" }
Works with $2 containing the .!? character and $1 containing the sentence.
Reply }


Messages In This Thread
RE: (Regular Expression) Letter Count - by MechanicalPen - 03-15-2014, 12:27 AM



Users browsing this thread: