Regex Pattern to Capture JIRA Keys

I need a regex to extract JIRA keys (format: LETTERS-digits) from text without fixed delimiters. Example:

for my $record (@lines) {
    if ($record =~ /\b([A-Z]+-\d+)\b/) {
        push @issues, $1;
    }
}

hey, try using /\b([A-Z]±\d+)\b/ but i found /(?:^|\s)([A-Z]±\d+)(?=\s|$)/ worked better for texts with odd spacings. hope it hlps!

In my experience working with similar JIRA key extraction tasks, I found that a slight modification to the regex can handle cases where punctuation or special characters are involved. I began experimenting with incorporating look-arounds to ensure that extra characters do not interfere with matching. One variant that I used was /(?<=\b|[^A-Za-z0-9])([A-Z]±\d+)(?=\b|[^A-Za-z0-9])/. This approach worked well in diverse scenarios, capturing only proper keys and reducing false positives when no clear delimiters were present.

Working on a similar project, I encountered issues with keys sometimes being attached to punctuation or being embedded in longer strings. I experimented with different boundary conditions before landing on a variant that accounted for non-word characters without being too strict. Personally, I settled on using a regex that employs look-behind and look-ahead assertions to safely capture only the intended pattern even when extra delimiters are present. Testing against a variety of sample texts was key to ensuring the solution reliably extracted the correct keys in all scenarios.