Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

scriptrunner Matcher cannot be cast to java.lang.Double


I'll admit I'm not very good at this and have been struggling for days. I've actually reached the end of the information highway and resorted to going 3 pages deep in Google. I'm trying to use ScriptRunner (Listeners) during a issue creation to match description field with Regex (which works) and then insert into a Custom Field. I feel like I'm close, but I'm now having issues with data conversion:

java.util.regex.Matcher cannot be cast to java.lang.Double

I'm guessing it's barking about the Description field which I did getClass:

description: class java.lang.String

I know the Custom Field is a Number Field, since I created it. Here's what I've written, please don't beat up on my:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import java.util.regex.Matcher
import java.util.regex.Pattern

def issueManager = ComponentAccessor.getIssueManager()
log.error("Key: " + event.issue.getKey())
def currentIssue = issueManager.getIssueObject(event.issue.getKey())
log.error("issue: " + currentIssue)
log.error("description: " + currentIssue.description)
log.error("description: " + currentIssue.description.getClass())

Matcher RegExResult = (currentIssue.description =~ /Member Number:.*?} ([1-9][0-9]{4,22})/)

def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find { == "Foo Number"}
def changeHolder = new DefaultIssueChangeHolder()

tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), RegExResult),changeHolder)


I'd appreciate any help or input, this has been very frustrating - Thanks in advance!

1 answer

0 votes

If you want to access specific capture groups in your matcher, you need something like


If you run this in the console

def test = "something Member Number: } 112346 something else"
def RegExResult = test =~ /Member Number:.*?} ([1-9][0-9]{4,22})/

You will get an array result like this:

[Member Number: } 112346, 112346]

The first item in the array if the full match. Each subsequent item is a capture group.

So to get the actual number, you want to first match [0] and the second item in the list [1]

But you may have an error in your pattern, are you really expecting a } after Member Number?

If you want to find 1123456 in a string like "something Member Number: 112346 something else", then your pattern should be /Member Number:.*?([1-9][0]9{4,22})/

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

228 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you