How to use RegEx Expression to spilt items like this?

What is the regex expression to spilt an expression like the ones shown below:
Nationality(space)(space)SOUTH KOREAN (note: double space)
Nationality(space)(space)JAPANESE (note: double space)

1 Like

Hey @_itslw,

Here is a bit different workaround for you.

Assuming your data stored in variable named location.

location.Substring((“Nationality”.Length)-1).Trim

This will give you the nationality value.

Hope this helps you.

Thanks :slight_smile:

I got the output of “y(space)(space)South Korean”. as mentioned, my variable has two spaces before the word “South Korean”.

1 Like

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Split(text,"\s\s")(1)

or

System.Text.RegularExpressions.Regex.Match(text,"(?<=Nationality\s\s).*").Value

These expressions return SOUTH KOREAN or JAPANESE.

Regards,

1 Like

@_itslw Remove the -1 from the expression please

Thanks :slight_smile: