Trying to parse string from a website that gives device status with a value at the end
I’m using ruby and trying to get a value from a string that I received from an URI.PARSE.
Below is what I get back from the URI.PARSE and is in my string. You can see it in the result at the bottom. Q8:0; I only need the Device which in this case is Q8 and the value is 0. The device is always a string but sometimes the value is a string and sometimes a integer. I want to be able to evaluate this result to do events based on the values.
- How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'”
- Rails app can run locally, but cannot deploy in Heroku website. Heroku shows The page you were looking for doesn't exist
- Merb having issues requiring gems
- PostgreSQL Error on Heroku with “BETWEEN”
- How do I debug an undefined method for nil class error?
- Rendering partials / view in a rake task / background job / model in Rails 4
html code>Q8:0;html code
One Solution collect form web for “Trying to parse string from a website that gives device status with a value at the end”
_, device, value, _ = "html code>Q8:0;html code".split(/[>:;]/)