extract value from String using regex:

tkrishna29
Giga Guru

Hi,

I have the following text in one of our fields - 

var str = 'Running: Yes
Link status: Connected to cloud.xxx.com:
UUID: a49167c7-xxx-yyy-zzz-01234567zx00';

I need to extract the UUID value from this text and update it to one of our UUID fields. How can I extract this UUID tag value? Greatly appreciate your help. Thank you.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Try below in background script once.

var str = 'Running: Yes Link status: Connected to cloud.xxx.com: UUID: a49167c7-xxx-yyy-zzz-01234567zx00';
var splittogettext=str.split('UUID:')[1];//This gives text after UUID
gs.print(splittogettext);

View solution in original post

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Try below in background script once.

var str = 'Running: Yes Link status: Connected to cloud.xxx.com: UUID: a49167c7-xxx-yyy-zzz-01234567zx00';
var splittogettext=str.split('UUID:')[1];//This gives text after UUID
gs.print(splittogettext);

Hi Jaspal,

I think it should be:

var str = 'Running: Yes Link status: Connected to cloud.xxx.com: UUID: a49167c7-xxx-yyy-zzz-01234567zx00';
var splittogettext=str.split('UUID: ')[1];//This gives text after UUID
gs.print(splittogettext);

Otherwise the splittogettext variable will have one whitespace at the start of the variable and this will probably cause issues if the value is being used elsewhere.

 

Yes. Agreed.

tkrishna29
Giga Guru

Thanks a lot. I thought I have to use regex.match() to get this value from the expression.