Skip to main content

Note: only change exact word not combination words .

it posible change exact multiple words in StringReplacer and StringPaireReplacer

rock=Star

 

 

nove=9

 

 

 

 

 

RAW sourceNormalized

 

nove9correctnovember9mberincorrectrockStarcorrectrockstarStarstarincorrect

With StringReplacer, you can use Regular Expression mode to be a lot more flexible in what is allowed, and what is not allowed, to be replaced.

You can test it in any number of online Regular Expression testers like:

https://regexr.com/

https://regex101.com/

For example, using a regular expression test = \\b[N|n]ove\\b in StringReplacer will restrict replacements to where only "nove" or alternatively "Nove" is a word by itself. The "\\b" expressions are placeholders for word boundaries such as the space character or the start of line or end of line characters. So whilst "nove" would be match, using the above regular expression "november" would not, because the letter "m" is not a word boundary character.

 

Unfortunely StringPairReplacer cannot use Regular Expressions, but one method may be to instead use a pre-processor like StringSearcher, which can use Regular Expressions.

With StringSearcher you could use \\bzero\\b|\\buno\\b|\\bdue\\b.... to find any words that are "number words" (the "|" expression is the equivalent of "or") and separate this out as their own string result number words. Then you could use StringPairReplacer on these results to replace the "number word" with its equivalent digit and then merge this result back into the original string at the place within the original string.


You can do this with just two transformers, a Tester and a StringPairReplacer. If you have a list of the words you can make a comma separated list of them for the Tester, using the In operator and set Comparison mode to Case insensitive if that is correct for you. Then you send the features that passed the test into the StringPairReplacer where you do the substitutions. The features that didn't pass should be led outside the StringPairReplacer and join the substituted features afterwards.


You can do this with just two transformers, a Tester and a StringPairReplacer. If you have a list of the words you can make a comma separated list of them for the Tester, using the In operator and set Comparison mode to Case insensitive if that is correct for you. Then you send the features that passed the test into the StringPairReplacer where you do the substitutions. The features that didn't pass should be led outside the StringPairReplacer and join the substituted features afterwards.

it is work for exact words but I have combination words

like

novenove ratnagrd rock novegrd nove ratna novembernovembergrd nove ratna

 

 

note: I have to change for roman number

check below it is for roman number Vi (6) and give betterment and for bulkwords also

Stringpair_replacer.fmw


With StringReplacer, you can use Regular Expression mode to be a lot more flexible in what is allowed, and what is not allowed, to be replaced.

You can test it in any number of online Regular Expression testers like:

https://regexr.com/

https://regex101.com/

For example, using a regular expression test = \\b[N|n]ove\\b in StringReplacer will restrict replacements to where only "nove" or alternatively "Nove" is a word by itself. The "\\b" expressions are placeholders for word boundaries such as the space character or the start of line or end of line characters. So whilst "nove" would be match, using the above regular expression "november" would not, because the letter "m" is not a word boundary character.

 

Unfortunely StringPairReplacer cannot use Regular Expressions, but one method may be to instead use a pre-processor like StringSearcher, which can use Regular Expressions.

With StringSearcher you could use \\bzero\\b|\\buno\\b|\\bdue\\b.... to find any words that are "number words" (the "|" expression is the equivalent of "or") and separate this out as their own string result number words. Then you could use StringPairReplacer on these results to replace the "number word" with its equivalent digit and then merge this result back into the original string at the place within the original string.

hi @bwn i tried but getting confusion please give berif and if possible check above comment, fwm and adjust for bulk words


I would like to use StringPairReplacer, but I cannot figure out how the pairs are entered. In curly brackets, i.e. a dict in Python? In any case, the documentation should include an example. Thanks!


I would like to use StringPairReplacer, but I cannot figure out how the pairs are entered. In curly brackets, i.e. a dict in Python? In any case, the documentation should include an example. Thanks!

Hi @bradosav​ The pairs are entered as just separated by a space. For example:

if the source attribute’s value was:

bobby

and the replacement pairs were:

b s o a

  • b will be replaced by s
  • o will be replaced by a

the result will contain:

sassy

 

You can find some examples of how to use the StringPairReplacer in the documentation under the General header.


I would like to use StringPairReplacer, but I cannot figure out how the pairs are entered. In curly brackets, i.e. a dict in Python? In any case, the documentation should include an example. Thanks!

You may also want to take a look at this question, where some possibilities are discussed that are not currently in the documentation.


Hi @bradosav​ The pairs are entered as just separated by a space. For example:

if the source attribute’s value was:

bobby

and the replacement pairs were:

b s o a

  • b will be replaced by s
  • o will be replaced by a

the result will contain:

sassy

 

You can find some examples of how to use the StringPairReplacer in the documentation under the General header.

Thanks, exactly what I was looking for!


You may also want to take a look at this question, where some possibilities are discussed that are not currently in the documentation.

Thanks! One of the screenshots in the question you referred to had the answer!


You may also want to take a look at this question, where some possibilities are discussed that are not currently in the documentation.

You're welcome, I'm glad I could be of help.


Reply