Alteryx Designer Desktop Discussions

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

Remove character Before , After & in between the String and add _ in between the string

AKPWZ
8 - Asteroid

I have a string field that looks like this "0.HTTP.2.WebText"  (a JSON_Name field).

 

And I want to remove the unwanted character using regex or any other formula in my workflow to achieve the output.

The output should look like this - "HTTP_WebText".

Any idea how to solve this, please? Thanks.

 

20 REPLIES 20
atcodedog05
22 - Nova
22 - Nova

Hi @AKPWZ 

 

Give this a try

 

REGEX_Replace([Input], ".*(HTTP).*\.(.+)", "$1_$2")

 

Workflow:

atcodedog05_0-1627556138258.png

 

Hope this helps : )

AKPWZ
8 - Asteroid

Hi @atcodedog05 

Thank you so much for your response.

Just want to know how can I replace the HTTP string (hardcoded text) with an alphanumeric regex. 

Coz I have only one row which contains HTTP text, but other rows contain different strings.

 

Ex: 

"0.TCP.1.Error"

"0.HTTP.2.WebText"

"0.Loop.3.Response"

"0.WEB.4.WebText"

 

So, I used this "^[a-zA-Z0-9]+$" regex in place of "HTTP" but it's not working for me. Can you please guide me. Thanks

Jean-Balteryx
16 - Nebula
16 - Nebula

Hi @AKPWZ ,

 

I adapted @atcodedog05 right answer to suit your new need :

 

REGEX_Replace([Field1], ".*\.(.*)\..*\.(.+)", "$1_$2")
atcodedog05
22 - Nova
22 - Nova

Hi @AKPWZ ,

 

Here is the Regex

 

REGEX_Replace([Field1], "\d+\.(\u+)\.\d+\.(.+)", "$1_$2")

 

Workflow:

atcodedog05_0-1627560904641.png

 

Hope this helps : )

 

AKPWZ
8 - Asteroid

Wow, this is working fine for me @Jean-Balteryx @atcodedog05 Thank you so much 🙂 🙂

Just want to clear one more small doubt what if I have a trend of different kind of data then in that condition what changes will I make to achieve the same output?
For Ex: 

"0.TCP"

"0.HTTP"

"0.Loop.1.Response"

"0.WEB.2.WebText.3.Wire"

"0.WEB.4.WebText.5.Wire.6.Net"

 

Thanks!

Jean-Balteryx
16 - Nebula
16 - Nebula

Do you which to get everything that is not digits ?

atcodedog05
22 - Nova
22 - Nova

Hi @AKPWZ 

 

Can you provide the expected output for the above?

AKPWZ
8 - Asteroid

Hi @atcodedog05 

 

Yes, Here is the expected output:

 

TCP

HTTP

Loop_Response

WEB_WebText_Wire

WEB_WebText_Wire_Net

 

Thanks!

Jean-Balteryx
16 - Nebula
16 - Nebula

Then try this formula : 

 

TrimLeft(Replace(REGEX_Replace([Field1], "\d", "_"), ".", ""), "_")
Labels