How would I find and replace '49' when '49' will be an unknown id, using ruby on rails?
str = "select * from clients where client_id = 49 order by registration_date asc"
str = str.gsub(/someRegExThatFinds49/, replacement_id) # <------ Here's the concept
Looking for a syntax and example that's correct. Thanks.
gsub, which will replace all occurrences of the regex in the string. If you know your numeric ID will always be the first number in the string, regularsubwill be safer, as it only replaces the first match. If your ID could be at any position, possibly with other numbers before it, regices probably aren't what you're looking for. It'd just be too easy to screw things up.