Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Formatting a Text String

G_Thompson
8 - Asteroid

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.

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

@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 restart. Order shall return.
Please Subscribe to my youTube channel.
G_Thompson
8 - Asteroid

@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
20 - Arcturus
20 - Arcturus

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 restart. Order shall return.
Please Subscribe to my youTube channel.
grazitti_sapna
17 - Castor

Hi @G_Thompson,

 

Let me now if this solves your purpose.

 

 

Sapna Gupta
Labels