const regex = /[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(?=')/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(?=\')', 'g')
const str = `(SU 08624476) Shrewton 5b; Mutilated, diameter approx. 20 paces, height approx 3'. (1)
SU 08624475: Shrewton 5b; site only, diameter 22m, plotted from AP at 1:2500 (2,3)
Barrow, no recorded excavations taken place. (4)
The cropmark remains of the Bronze Age bowl barrow described by the previous authorities were seen as a ring ditch with a diameter of 30m centred at SU 0862 4475. It was mapped at 1:10,000 scale as part of the RCHME: Salisbury Plain Training Area NMP Project, and subsequently revised for the English Heritage Stonehenge WHS Mapping Project. This barrow was recorded collectively with four other barrows in NMR record SU04SE 31 as a barrow cemetery. Eight further barrows from the eastern end of the same cemetery lie immediately to the south of the modern road. These have been recorded separately in NMR record SU04SE 26. (5)
1
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
VCH Wilts 1, 1957, 190 (L.V Grinsell)
2
Aerial photograph
AP (Crawford Collection 1097, undated)
3
Field Investigators Comments
F1 PAS 21-Nov-1974
4
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
Proc. Prehistoric Soc. 50, 1984, 257 (C. Green, S. Rollo-Smith)
5
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
NMR OS/70067 218 03-MAY-1970
1
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
VCH Wilts 1, 1957, 190 (L.V Grinsell)
2
Aerial photograph
AP (Crawford Collection 1097, undated)
3
Field Investigators Comments
F1 PAS 21-Nov-1974
4
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
Proc. Prehistoric Soc. 50, 1984, 257 (C. Green, S. Rollo-Smith)
5
VIRTUAL CATALOGUE ENTRY TO SUPPORT NAR MIGRATION
NMR OS/70067 218 03-MAY-1970
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions