Question

Remove variable text from string.


I have this output

["*Nps*","4 out of 10","*Why*","Great"], null, ["*IsStaff*","true ","*IsActive*","true ","*UserId*","auth0|5a577dxxxxxxx228a03e564c ","*IsTrial*","false ","*HasNoSubscription*","false "], ["*SubscriptionStatus*","{\"enableReview\":true,\"enableRise\":true,\"plan\":\"team\",\"status\":\"active\",\"endDate\":\"2028-06-13T00:00:00.000Z\",\"role\":\"seatHolder\",\"subscriptionId\":\"xxxxxx-4af4-4417-8fbd-xxxxx\",\"isRetrialEligible\":false,\"isTeamAdmin\":true,\"seats\":202}","*Platform*","Mac","*Browser*","Chrome 103.0.0.0","*Url*","<https://xxx.BlahBlah.zone/>","*Device type*","desktop"]

and need to extract only the auth0|5a577dxxxxxxx228a03e564c in the output. 

In trying to remove everything up to the value above, I’ve tried the following JavaScript to no avail:
 

let Response = inputData.Response.split(/"*Nps(.*)UserId*",":/g)[0]; output = [{Response}];

I started from this thread


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +12

@BretJorg 

try the following
 

let auth = inputData.Response.slice(inputData.Response.indexOf('auth'))
auth = auth.slice(0,auth.indexOf(","))
auth = auth.replace(/"/g,"")
return {auth}

 

Userlevel 7
Badge +14

Hi @BretJorg 

Good question.

Related help topic: