ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Formatting a Text String

G_Thompson
7 - Meteor

Hi everyone.

 

I'm driving myself crazy trying to format a text string into the required format!

 

My workflow is doing a load of stuff but the crux of the issue is this ... I currently have a string that looks like this;

 

name: site test GT,    address: test address,    city: Newcastle,    state: VIC,    postcode: 2000,    siteContact: test,    siteEmail: test@test.com,    portfolio: Suburban 2,    propertyId: 123456,    fmEmail: test@fm.com,    fmMobile: 01234567,    pmEmail: test@pm.com,    pmMobile: 987465,    propertyType: Leased,    department: CDPP, oneViewClientPropertyID: 12345678

 

I need it to look like this:

 

{"name": "site test GT",    "address": "test address",    "city": "Newcastle",    "state": "VIC",    "postcode": "2000",    "siteContact": "test",    "siteEmail": "test@test.com",    "portfolio": "Suburban 2",    "propertyId": "123456",    "fmEmail": "test@fm.com",    "fmMobile": "01234567",    "pmEmail": "test@pm.com",    "pmMobile": "987465",    "propertyType": "Leased",    "department": "CDPP", "oneViewClientPropertyID": "12345678"}

 

I'm hoping somebody can help with the additions of the " and {}

 

Many thanks in advance.

MarqueeCrew
19 - Altair
19 - Altair

@G_Thompson 

 

'{"' + Replace(replace(REGEX_Replace([Input], "\s+", ' '),": ",'": "'),", ",'", "') + '"}'

 

It will always make 1 space after your commas.

 

Cheers,

 

Mark 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
G_Thompson
7 - Meteor

@MarqueeCrew 

 

Many thanks. As you'll see, the below is actually creating { and } at the beginning and end of every field. { actually only needs to be the very first character and } the very last i.e. group the whole string within { and }

MarqueeCrew
19 - Altair
19 - Altair

Hopefully it gets you or others close to the solution. 

sorry, but I'm back to caring for my dogs now.

 

 Cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and reboot. Order shall return.
grazitti_sapna
15 - Aurora
15 - Aurora

Hi @G_Thompson,

 

Let me now if this solves your purpose.

 

 

Sapna Gupta
Labels