I'm using Rails/ActiveRecord/Postgres. Here is a sample test string I'm trying to match -
:sample_data => "$$352054054640611,1010,2015/02/24,05:20:30,40.28370,-111.65530,1437.1,0,0,0,0,0.0,7,0.9,1010,0.0,12.2,8,1,0,81.3##"
I only want to query for the first number after the first comma (ex: 1010). In Rails I was looking to do something like this.
number = "1010"
Model.where("sample_data ~* ?", "\$\$.*," + number + ",.*")
The problem is it looks like Postgres isn't allowing me to escape the two dollar signs like I hoped.
Edit
When I run Model.where("sample_data ~* ?", "\$\$.*," + number + ",.*").to_sql
I get -
"SELECT \"Model\".* FROM \"Model\" WHERE (sample_data ~* '$$.*,1010,.*')"
Model.where("sample_data ~* ?", "\$\$.*," + number + ",.*").to_sqlModel.where("sample_data ~* ?", "\\$\\$.*," + number + ",.*")Model.where("sample_data ~* ?", "\\$\\$(\\c+),1010,.*")