Help with Regex statement in Ruby

Posted by user336777 on Stack Overflow See other posts from Stack Overflow or by user336777
Published on 2010-05-12T00:13:55Z Indexed on 2010/05/12 0:44 UTC
Read the original article Hit count: 231

Filed under:
|

I have a string called 'raw'. I am trying to parse it in ruby in the following way:

raw = "HbA1C ranging 8.0—10.0%" raw.scan /\d*.?\d+[ ](-+|\342\200\224)[ ]\d*.?\d+/

The output from the above is []. I think it should be: ["8.0—10.0"].

Does anyone have any insight into what is wrong with the above regex statement?

Note: \342\200\224 is equal to '—'.

The piece that is not working is: (-+|\342\200\224)

I think it should be equivalent to saying, match on 1 or more '-' OR match on the string \342\200\224.

Any help would be greatly appreciated it!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about regex