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

Remove special characters only before/after text

joannasokolowska
8 - Asteroid

Hi Colleagues,

I would like to ask you for advice regarding removing special characters. I tried to use Regex but because the special character is " // " then it is read as part of the formula. 

 

I would like to remove "//" only when there is not text before/after/ Please see the example. 

 

Current situation

1. // // text1 // text2

2. text1 //

3. text1 // // text2

 

Desire outcome

1. text 1 // text 2

2. text 1

3. text 1 // text 2

 

Thank you in advance,

Asia

 

6 REPLIES 6
atcodedog05
22 - Nova
22 - Nova

Hi @joannasokolowska ,

 

Use the below formula in formula tool.

 

TrimLeft(TrimRight(Replace([Field1], "// //", "//"),"//"),"//")

Output:

atcodedog05_0-1601893121715.png

Workflow:

atcodedog05_1-1601893135490.png

Hope this helps 🙂

 

If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

RolandSchubert
16 - Nebula
16 - Nebula

Hi @joannasokolowska ,

 

you want to remove only leading/trailing "//"? Formula tool can be used to do this, I think, RegEx is not needed.

 

I've attached a workflow. Let me know if it works for you, especially line 3 ("// //" is not replaced by "//" matching your description, but not the sample.

 

2020-10-05_12-38-03.png

 

 

 

Best,

 

Roland

grazitti_sapna
17 - Castor

Hi @joannasokolowska , if you want to perform it using regex you need to use 2 regex tool first to replace // // with // and then removing leading and trailing //. Please refer to the screenshot and workflow.

grazitti_sapna_0-1601895303227.png

 

Thanks.

 

Sapna Gupta
joannasokolowska
8 - Asteroid

Thank for the quick help! Is there a way to not limit number of  //  ? I didn't mention before but there could be more situations where I have e.g. text1 // // // text2 // // // // // // text 3 etc. 

 

Thanks,

Asia

atcodedog05
22 - Nova
22 - Nova

Hi @joannasokolowska 

 

Not my best work. But here the workflow. I have nested multiple(like a lot) replace to replace // // to //. 

 

Output:

atcodedog05_1-1601899817213.png

Hope this helps 🙂

 

If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

atcodedog05
22 - Nova
22 - Nova

Happy to help 🙂 @joannasokolowska 

 

Cheers and happy analyzing 😀

Labels