Skip to main content
Gathering Interest

Improve StringReplacer to allow Multiple String Replacements

Related products:Transformers
rmurphy
mohamad22
rylanatsafe
mkludas
+129
  • rmurphy
    rmurphy
  • mnikosz
  • mohamad22
    mohamad22
  • rylanatsafe
    rylanatsafe
  • mkludas
    mkludas
  • medici
    medici
  • hvukasinovic
    hvukasinovic
  • cshepard
    cshepard
  • siennaatsafe
    siennaatsafe
  • ebygomm
    ebygomm
  • takashi
    takashi
  • geomancer
    geomancer
  • danilo_fme
    danilo_fme
  • caracadrian
    caracadrian
  • jdh
    jdh
  • erik_jan
    erik_jan
  • sigtill
    sigtill
  • warrendev
    warrendev
  • tcrossman
    tcrossman
  • vxn43
    vxn43
  • thijsknapen
    thijsknapen
  • jkr_wrk
    jkr_wrk
  • carmijo
    carmijo
  • runneals
    runneals
  • bruceharold
    bruceharold
  • joepk
    joepk
  • nic_ran
    nic_ran
  • jelle
    jelle
  • panda
    panda
  • kennyo
    kennyo
  • michiedem
    michiedem
  • chriswilson
    chriswilson
  • philippeb
    philippeb
  • jackyd
    jackyd
  • canerakin
    canerakin
  • antoine
    antoine
  • arthur_bazin
    arthur_bazin
  • milo89
    milo89
  • jonathanklarup
  • jeroenstiers
  • matthieuv
    matthieuv
  • juandiegoboh
  • bibold
  • gbj1717
    gbj1717
  • revesz
    revesz
  • spatialexjames
    spatialexjames
  • denizturan1985
  • softwrite1
    softwrite1
  • jpsalva
    jpsalva
  • xav_cap
  • kevs-2021
    kevs-2021
  • cj
  • rottens
  • pi_hellz
    pi_hellz
  • kcoats
    kcoats
  • pwan
  • pcgveenstra
    pcgveenstra
  • ronk
  • ewoudvdc
    ewoudvdc
  • digit42
    digit42
  • gary
  • ml56067
    ml56067
  • nordpil
    nordpil
  • kahlen
    kahlen
  • osmanbeg1980
    osmanbeg1980
  • r5
    r5
  • carstenotto
    carstenotto
  • erooen
  • lindsay
    lindsay
  • travg
    travg
  • geolassi
    geolassi
  • littlefictions
    littlefictions
  • nixynoodle
    nixynoodle
  • alexd
  • chickey
    chickey
  • roland
    roland
  • mvanwie
    mvanwie
  • susannebell
    susannebell
  • mbz
    mbz
  • wizdatawizard
    wizdatawizard
  • lbarrufat
    lbarrufat
  • mygis
    mygis
  • alexandreroy
    alexandreroy
  • ecthelion
    ecthelion
  • mmccart
    mmccart
  • geogaard
    geogaard
  • davidlee
    davidlee
  • felipeverdu
    felipeverdu
  • johnt
    johnt
  • dhaulagiri
    dhaulagiri
  • marnickcle
    marnickcle
  • gabriel_hirsch
    gabriel_hirsch
  • flugan87
  • danielkroon
    danielkroon
  • kalbert
    kalbert
  • hth
    hth
  • gavinpark
    gavinpark
  • jakethepainter
    jakethepainter
  • ravibansal
    ravibansal
  • edhere
  • anari
    anari
  • bobw
    bobw
  • taojunabc
    taojunabc
  • kim
  • frro
    frro
  • setld_solutions
    setld_solutions
  • geoportalcartog
    geoportalcartog
  • tnarladni
    tnarladni
  • geoal
    geoal
  • ghattas111
  • reedwhit
    reedwhit
  • vhruska
    vhruska
  • bertd
  • jmiddel
    jmiddel
  • hrvoje
    hrvoje
  • phoeffler
    phoeffler
  • joeri
    joeri
  • 1200ks
  • ccantu
    ccantu
  • tlabs
  • luigidd
    luigidd
  • j_ganalyst
  • battlezone77
  • olga
  • firework_girl
  • rhansen
  • chris
  • andrejacquet
  • fmeinfoaggregat
  • thomaswood
  • maja
    maja
  • dmitribagh
    dmitribagh
  • mskg
    mskg
  • nison
    nison

takashi
Supporter
For example, if you need to replace suffix {a, b, c} with {x, y, z}, you will have to use three StringReplacers with different regular expressions. In this example, the StringPairReplacer cannot be used since the source string contains a, b, c within the non-suffix part.
sourcedestination
1abcaabcx
2abcbabcy
3abccabcz
I think the StringReplacer has a room to improve to allow users to define one or more replacement rules. Probably the parameters setting for the above example looks like this.
If the user defined two or more replacement rules, the transformer performs every replacement in the order from top to bottom.

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 29, 2016

Two other potential improvements:

 

 

Allow the stringReplacer to use List Attributes directly.

 

 

Optionally return an attribute with statistics (3 replacements were made)

 


mark2atsafe
Safer
Forum|alt.badge.img+43

Have you tried using conditional values here?

For example, using takashi's scenario, you should be able to replace the StringReplacers with a single AttributeManager. The value is set to conditional (eg if attribute ends-in a) and uses a regex function in the text editor (@ReplaceRegEx(attribute,$a,x))

See this example:

https://www.dropbox.com/s/oahudexz43imgva/LastCharacterMapper.fmw?dl=0


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • February 9, 2016

Filed as PR 68066


Forum|alt.badge.img+2

@takashi Do you know of any other applications that offer this type of functionality that we could use as a

 


setld_solutions
Contributor
Forum|alt.badge.img+7

Hoping this will allow spreadsheet / table import, also. Thanks!


jackyd
Contributor
Forum|alt.badge.img+10
  • Contributor
  • March 15, 2020

This is great if your attribute only meets one of the conditions, what about if your attribute meets 2 or more conditions?


mark2atsafe
Safer
Forum|alt.badge.img+43

You can set up conditions to be AND or OR statements (or a mix of both) so you can hopefully use those to set up multiple conditions in any way you need. The first condition that is met, is the one that applies, so if you want to apply more than one result, then you'd need to use a separate line in the AttributeManager, or use a series of transformers.


gabriel_hirsch
Contributor
Forum|alt.badge.img+11

A small improvement with the StringPairReplacer would be to be able to use an attribute for Replacement Pairs


ecthelion
Contributor
Forum|alt.badge.img+12
  • Contributor
  • June 28, 2022

This would be so useful - I quite often look for other solutions than using multiple StringReplacers.


pradip
Participant
Forum|alt.badge.img+2
  • Participant
  • June 21, 2023

@Takashi Iijima​ Thanks for sharing an idea. I tried creating a custom transformer for it.

Hope this works !

https://hub.safe.com/publishers/spatial-kat/templates/stringreplacer_multiple


LizAtSafe
Safer
Forum|alt.badge.img+15
OpenGathering Interest

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings