How to replace a string contains in another string using regular expression

  • 7 February 2018
  • 5 replies
  • 14 views

Badge +5

Hi everyone,

I have a to be replaced text in this format: "dd ame". I want to replace this text in a multiline field using regular expression. 

Tried different things like "dd\name" or "dd/ ame" or "dd*\\"" in pattern and still couldn't figure that out.

Does anybody have an idea?

Thanks!


5 replies

Userlevel 5
Badge +14

what about this pattern?

w+\w+

213282_pastedImage_1.png

Badge +5

Thanks Martin,

The pattern works perfectly for replacing but how can I tell to replace before and after words if they're matched?

here is the example if signer = nassafari => Replace nassafari with "Replaced".

if signer = aamhatala => Replace  aamhatala with "Replaced".

213297_pastedImage_1.png

Thanks

Userlevel 5
Badge +14

I'm not sure I understand what you mean.

the pattern I suggested replaces any two consecutive words split by single backslash. do you mean to replace only exact string pattern? so eg if there appear nassafari in the text then replace it, but if there appears eg. anssafari then do not replace it?

if so, then your pattern simply should look like

na\ssafari

213312_pastedImage_1.png

Badge +5

I figured that out,

na\ssafari will replace nassafari in a string.

Userlevel 5
Badge +14

great!

if you've got a solution please mark question answered.

Reply