Forum Discussion
Extract List of Records from String
Hi Experts,
I have one specific requirement to extract number of PO Orders from the strings, the PO orders starts with "OCD" or "COD" and 4 digit number, the users input is free text so we recieve it in many ways like the below. Could you please kindly help to solve this scenario. Thanks in advance
Input Table
| Order | StringColumn with PO numbers |
| 256 | Yes that’s the OCD 1266 and OCD - 1556 and COD 1566, 1565 and 1565 |
| 257 | Ok COD 1563 and 2569 |
| 258 | Current OCD is 1596 and 1569 |
Expected Table
Order | Extracted PO numbers |
256 | OCD 1266 |
| 256 | OCD 1556 |
| 256 | COD 1566 |
| 256 | COD 1565 |
| 256 | COD 1565 |
| 257 | COD 1563 |
| 257 | COD 2569 |
| 258 | OCD 1596 |
| 258 | OCD 1569 |
Thank you ribisht17 I found the way using RegEx
let fx=(txt as text, regex as text, delim as text)=>
Web.Page(
"<script>
var x = '" & txt & "';
var delim = '" & delim & "';
var pattern = /" & regex & "/gi;
var result = x.match(pattern).join(delim);
document.write(result);
</script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0}
in
fx
4 Replies
- ribisht17Super User
Cool 🙂
- ribisht17Super User
- k_mathanaHelper II
Thank you ribisht17 I found the way using RegEx
let fx=(txt as text, regex as text, delim as text)=>
Web.Page(
"<script>
var x = '" & txt & "';
var delim = '" & delim & "';
var pattern = /" & regex & "/gi;
var result = x.match(pattern).join(delim);
document.write(result);
</script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0}
in
fx