If I have a list of numbers like this:
list = {0.3565127, 0.8656421, 0.231479879, 0.39698787, 0.536987651},
which are all between 0 and 1, each having lots of digits, and whose precision is not known (and also not important). I don't know their exact values. (It could be a list of hundreds of numbers, so we don't know each of them exactly).
Yet I know some of them have the form 0.?969?????????, where the ?s represent digits I do not know; besides; the digits known are all within the first five digits behind the decimal point.
So, how can I construct a pattern object (like x_^2 for symbols) for replacing numbers that match the pattern?
Dropwill be safer, andPatternSequenceseems to be redundant.MatchQ[ Drop @@ RealDigits[1.096956], {_, 9, 6, 9, __} ]– Kuba Feb 23 '16 at 10:45Dropdoesn't seem to do the trick all the time either, seeDrop @@ RealDigits[0.063548]– Jason B. Feb 23 '16 at 10:53RealDigitsoutput doesn't fit list manipulation practices in MMA. – Kuba Feb 23 '16 at 11:03MatchQ[RotateLeft @@ (RealDigits[22.1111111111111111]), {_, 1 .., 2, __}]– Kuba Feb 23 '16 at 11:10Quiet[]necessary:{0.969, 0.0969, 0.00969, 0.3565127, 0.8656421, 0.231479879, 0.39698787, 0.536987651} /. a_ /; MatchQ[First[RealDigits[a, 10, Automatic, -1]], {_Integer, 9, 6, 9, __Integer}] -> 4. – J. M.'s missing motivation Feb 23 '16 at 12:53