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