A work machine comprising: a slider that is held on a holding section so as to be movable in a specified direction; and two work heads (24, 26, 156, 158) that are detachably attached to the slider; wherein the slider has a main body (112, 114), a first attachment section that is provided on the main body (112, 114) and to which one of the two work heads (24, 26, 156, 158) is attached, and a second attachment section to which the other of the two work heads (24, 26, 156, 158) is attached, the second attachment section being provided on the main body (112, 114) at any one of multiple attachment locations provided at multiple set distances from the first attachment section that are set in advance in the specified direction such that the distance between the first attachment section and the second attachment section is changeable in the specified direction, the work machine further comprising multiple detected sections (194, 196) provided on one of the main body (112, 114) and the second attachment section spaced at a distance extending in the specified direction; and an attachment section spacing distance detector that is provided on the other one of the main body (112, 114) and the second attachment section, has multiple sensors (172, 174, 176, 178) spaced at a distance extending in the specified direction which detect the multiple detected sections (194, 196), and detects the distance between the first attachment section and the second attachment section by the detection of at least one of the multiple detected sections (194, 196) by two of the sensors (172, 174, 176, 178) out of the multiple sensors (172, 174, 176, 178), the attachment section spacing distance detector detects the distance between the first attachment section and the second attachment section by the detection of the multiple detected sections (194, 196) by two sensors (172, 174, 176, 178) which are not adjacent to each other among the multiple sensors (172, 174, 176, 178), or by the detection of at least one of the multiple detected sections (194, 196) by two sensors (172, 174, 176, 178) which are adjacent to each other among the multiple sensors (172, 174, 176, 178). a slider that is held on a holding section so as to be movable in a specified direction; and two work heads (24, 26, 156, 158) that are detachably attached to the slider; wherein the slider has a main body (112, 114), a first attachment section that is provided on the main body (112, 114) and to which one of the two work heads (24, 26, 156, 158) is attached, and a second attachment section to which the other of the two work heads (24, 26, 156, 158) is attached, the second attachment section being provided on the main body (112, 114) at any one of multiple attachment locations provided at multiple set distances from the first attachment section that are set in advance in the specified direction such that the distance between the first attachment section and the second attachment section is changeable in the specified direction, wherein the slider has a main body (112, 114), a first attachment section that is provided on the main body (112, 114) and to which one of the two work heads (24, 26, 156, 158) is attached, and a second attachment section to which the other of the two work heads (24, 26, 156, 158) is attached, the second attachment section being provided on the main body (112, 114) at any one of multiple attachment locations provided at multiple set distances from the first attachment section that are set in advance in the specified direction such that the distance between the first attachment section and the second attachment section is changeable in the specified direction, the work machine further comprising multiple detected sections (194, 196) provided on one of the main body (112, 114) and the second attachment section spaced at a distance extending in the specified direction; and an attachment section spacing distance detector that is provided on the other one of the main body (112, 114) and the second attachment section, has multiple sensors (172, 174, 176, 178) spaced at a distance extending in the specified direction which detect the multiple detected sections (194, 196), and detects the distance between the first attachment section and the second attachment section by the detection of at least one of the multiple detected sections (194, 196) by two of the sensors (172, 174, 176, 178) out of the multiple sensors (172, 174, 176, 178), the attachment section spacing distance detector detects the distance between the first attachment section and the second attachment section by the detection of the multiple detected sections (194, 196) by two sensors (172, 174, 176, 178) which are not adjacent to each other among the multiple sensors (172, 174, 176, 178), or by the detection of at least one of the multiple detected sections (194, 196) by two sensors (172, 174, 176, 178) which are adjacent to each other among the multiple sensors (172, 174, 176, 178).