Replace polish characters in a string

  • 17 November 2017
  • 2 replies
  • 50 views

Badge +1

Hi,

I need to find a way to replace polish characters (diactric) in a string/text. I need to replace "ŻÓŁĆĘŚĄŹŃżółćęśąźń" to "ZOLCESAZNzolcesazn".

I know I can use Replace function (fn-Replace) however it repalce a section of text in a larger string but I need to replace character or characters in a string.

Does anyone know how to do it?

Rafał


2 replies

Userlevel 7
Badge +17

Hi!

The idea that first came to my head is to create an UDA (User Defined Action, so that you can use it multiple times and manage in a single place), that has a DICTIONARY build from pairs: DIACRITIC CHAR: NON-DIACRITIC CHAR, ex.:

* ą:a

* Ą:A

* ć: c

* Ć: C

and so on...

Then make a for each loop, that will go through that dictionary and store both output and key in separate variables. In each loop use the "Regular Expression" action that will replace your current "key" (diacritic char) with a "value" (non-critic char). 

Regards,

Tomasz

Badge +1

Hi,

Thank you Tomasz Poszytek‌ for the tip however I have user other solution. In fact the same one you have propsed in this post - Need to create an Organizational Unit object in AD using Nintex Workflow  

In this case I have used PowerShell action from Aaron Labiosa: NTX PowerShell Action - Stable Release

Below is PowerShell script that solved this problem:

function Change-DiactricChars ( [string]$text ) {
$text`
-replace( “ą”,”a” )`
-replace( “ć”,”c” )`
-replace( “ę”,”e” )`
-replace( „ł”,”l” )`
-replace( „ń”,”n” )`
-replace( „ó”,”o” )`
-replace( „ś”,”s” )`
-replace( „ż”,”z” )`
-replace( „ź”,”z” )`
-replace( „Ą”,”A” )`
-replace( „Ć”,”C” )`
-replace( „Ę”,”E” )`
-replace( „Ł”,”L” )`
-replace( „Ń”,”N” )`
-replace( „Ó”,”O” )`
-replace( „Ś”,”S” )`
-replace( „Ż”,”Z” )`
-replace( „Ź”,”Z” )
}
Change-DiactricChars("some regional DiactricChars here like ąęćę")

Reply