Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Regular expressions problem
- - By Andrek Date 2013-02-14 09:49
Hi! i don't know much about regular expressions, however i use them but with this expression i have a problem, look:

/\[\d+\]/.match("text[2]") # => "2" Nice!
/\[\d+\]/.match("text[2]_plus[4]") # => "2" # Problem


So i use:
/\[\d+\]+/.match("text[2]_plus[4]") # => "2" Problem i need "4", the last

I don't know how solve problem, please help me.

PD: I don't speak english, sorry for the bad expressions.
Parent - - By erisdiscord Date 2013-02-15 00:13
This is more of a general Ruby question, but—

'text[2]_plus[4]'.scan(/\[\d+\]/) #=> ["[2]", "[4]"]
Parent - By Andrek Date 2013-02-15 04:35
Thanks a lot!! problem solve!!
Up Topic Gosu / Gosu Exchange / Regular expressions problem

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill