cancel
Showing results for 
Search instead for 
Did you mean: 

Get certain values of strings in array

JensDeveloper
Contributor II

Hi all,

I am trying to get the value between the ‘()’ of every record inside the array.

[
{ “betroffene IT Systeme”:[
“Ardoq·(431)”
“SnapLogic·(580)”
]
}
]
So that I get an array:
[ {
“betroffene IT Systeme”:[
“431”
“580”
]
} ]

My expressions language is still a bit rusty…

1 ACCEPTED SOLUTION

nsingam
Employee
Employee

Hi,

You can use the below expression.

$[‘betroffene IT Systeme’].map(x => x.substring(x.indexOf(“(”)+1, x.indexOf(“)”)))

View solution in original post

3 REPLIES 3

nsingam
Employee
Employee

Hi,

You can use the below expression.

$[‘betroffene IT Systeme’].map(x => x.substring(x.indexOf(“(”)+1, x.indexOf(“)”)))

alex_panganiban
Contributor

This also works and seems a little easier to understand. Instead of searching for the indexes of the open and close parenthesis and using a substring, it just removes everything that isn’t a numeric value. Great solution provided by nsingam, but in the spirit of offering you options, I thought I would share this one with you too. Definitely there are more than 1 way to skin a cat (horrible expression).

$[‘betroffene IT Systeme’].map(x => x.replace(/[^0-9]/g, ‘’))

Hi @alex.panganiban.guild

Thank you for your answer, much appreciated. That I haven’t tought about that also. Because I always only need the numbers.

Regards

Jens