Skip to main content
Solved

Extract number from string

  • September 25, 2023
  • 2 replies
  • 152 views

Forum|alt.badge.img
  • Contributor
  • 3 replies

I am trying to get the umber from the string but getting the “Invalid Syntax - One of its operands is invalid.” error, will someone help me with this.

substring('Your request to Terminate for Test User ID number 12345',indexOf(length(replace('Your request to Terminate for Test User ID number 12345 has been approved and has completed','has been approved and has completed','')),'number',0)
)

 

Best answer by Daniel Söderlund

moe72 wrote:

I am trying to get the umber from the string but getting the “Invalid Syntax - One of its operands is invalid.” error, will someone help me with this.

substring('Your request to Terminate for Test User ID number 12345',indexOf(length(replace('Your request to Terminate for Test User ID number 12345 has been approved and has completed','has been approved and has completed','')),'number',0)
)

 

You posted this in the Freshdesk forum :) 

Is the string fixed ? 
Just like to remove the tex in front of the number?

If it’s that you can do like this

{{ticket.subject | remove: ‘Your request to Terminate for Test User ID number ’ }}

That will give you the number only. 

With expression I should dom something like this 

substring('Your request to Terminate for Test User ID number 12345',
         indexOf('Your request to Terminate for Test User ID number 12345',
         'number ',0)+length('number '), 
    length('Your request to Terminate for Test User ID number 12345') 
)



 

View original
Did this topic help you find an answer to your question?

2 replies

Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
moe72 wrote:

I am trying to get the umber from the string but getting the “Invalid Syntax - One of its operands is invalid.” error, will someone help me with this.

substring('Your request to Terminate for Test User ID number 12345',indexOf(length(replace('Your request to Terminate for Test User ID number 12345 has been approved and has completed','has been approved and has completed','')),'number',0)
)

 

You posted this in the Freshdesk forum :) 

Is the string fixed ? 
Just like to remove the tex in front of the number?

If it’s that you can do like this

{{ticket.subject | remove: ‘Your request to Terminate for Test User ID number ’ }}

That will give you the number only. 

With expression I should dom something like this 

substring('Your request to Terminate for Test User ID number 12345',
         indexOf('Your request to Terminate for Test User ID number 12345',
         'number ',0)+length('number '), 
    length('Your request to Terminate for Test User ID number 12345') 
)



 


Forum|alt.badge.img
  • Author
  • Contributor
  • 3 replies
  • September 26, 2023

Thanks Daniel it works


Reply