Hi
Can anyone help me with this Regex formula I am trying to build? I think the & sign in group 4 is throwing out the formula as it is working for strings that don't have any special characters.
/[^0]*(\d{1,2}\/\d{1,2}\/\d{4})\s*(\D*)(\d{2}\s\D*)\s+([A-Z]{2,4}\D*)\s+([A-Z0-9]{2,4}\D*)(\d+\.?\d{0,2}?)\D+(\d+\.?\d{0,2})\D+(\d+\.?\d{0,2})\D+(\d+\.?\d{0,2})
/gm
07/22/2025 TEST TEST LLC 45 Loss Expenses D&O Directors & Officers Z0 Unknown or Unclassified 0.00 0.00 0 10.02
The output I am looking for is:
GROUP 1 | 07/22/2025 |
GROUP 2 | TEST TEST LLC |
GROUP 3 | 45 Loss Expenses |
GROUP 4 | D&O Directors & Officers |
GROUP 5 | Z0 Unknown or Unclassified |
GROUP 6 | 0.00 |
GROUP 7 | 0.00 |
GROUP 8 | 0 |
GROUP 9 | 10.02 |
Can anyone suggest how to amend it
Hi @Carlyn,
I built a regex that may suit your need, but with only one row of data it makes a bit hard to make it generic enough, here are some elements though :
^(\d{2}\/\d{2}\/\d{4})\s+(.*?)\s+(\d+\s+.+)\s+(D&O Directors & Officers)\s+(Z\d+.+)\s+(\d+\.?\d{0,2})\s+(\d+\.?\d{0,2})\s+(\d+\.?\d{0,2})\s+(\d+\.?\d{0,2})$
a few notes : I use /s for a space as a delimiter between groups
group | text part | regex | notes regarding the regex |
GROUP 1 | 07/22/2025 | (\d{2}\/\d{2}\/\d{4}) | |
GROUP 2 | TEST TEST LLC | (.*?) | |
GROUP 3 | 45 Loss Expenses | (\d+\s+.+) | |
GROUP 4 | D&O Directors & Officers | (D&O Directors & Officers) | this I could not generalize |
GROUP 5 | Z0 Unknown or Unclassified | (Z\d+.+) | I used Z but if it is an upper letter followed by a sumber could be \u\d+ |
GROUP 6 | 0.00 | (\d+\.?\d{0,2}) | |
GROUP 7 | 0.00 | (\d+\.?\d{0,2}) | |
GROUP 8 | 0 | (\d+\.?\d{0,2}) | |
GROUP 9 | 10.02 | (\d+\.?\d{0,2}) |
also, I always recommend trying to use websites like regex101 to test your regex, it helps you identify which part is causing troubles !
I hope it helps !
Hi, @Carlyn
Parse by RegEx:
(\d{1,2}\/\d{1,2}\/\d{4})\s*(\D*)(\d{2}(?:\s[[:alpha:]]+)+)\s+([A-Z&]{2,4}\D*)\s+([[:alnum:]]{2,4}\D*)(\d+\.?\d{0,2})\D+(\d+\.?\d{0,2})\D+(\d+\.?\d{0,2})\D+(\d+\.?\d{0,2})
Name | Value |
Txt | 07/22/2025 TEST TEST LLC 45 Loss Expenses D&O Directors & Officers Z0 Unknown or Unclassified 0.00 0.00 0 10.02 |
RegExOut1 | 07/22/2025 |
RegExOut2 | TEST TEST LLC |
RegExOut3 | 45 Loss Expenses |
RegExOut4 | D&O Directors & Officers |
RegExOut5 | Z0 Unknown or Unclassified |
RegExOut6 | 0.00 |
RegExOut7 | 0.00 |
RegExOut8 | 0 |
RegExOut9 | 10.02 |
The simplest approach may be to separate the elements with a delimiter rather than using regex, which would ensure you get the right elements if they change the patterns