Link to home
Start Free TrialLog in
Avatar of ethar turky
ethar turkyFlag for Saudi Arabia

asked on

use regular expression to change text

Dear all,
using c# can I change all database rows contains this:
<meaning>xxxxx</meaning>
TO
<meaning text="xxxxx" TextAR=""/>

I prefer to use regular expression.
( I just need the regular expression  implementation or even MS SQL SP)
Thanks,
Avatar of kaufmed
kaufmed
Flag of United States of America image

Change it where/how? Using Find/Replace in Visual Studio? In C# code? Other?

In any event, the pattern to match would be:

<meaning>([^<]+)</meaning>

Open in new window


...and the replacement would be:

<meaning text="$1" TextAR="" />

Open in new window


...assuming the utility that you are using to execute the replacement supports $n syntax. You might need to exchange "$1" for "\1" instead:

i.e.

<meaning text="\1" TextAR="" />

Open in new window

Avatar of ethar turky

ASKER

Thanks for your reply,
I am using c# VS 2013
So the replacement is taking place via C# code, using the Regex class?
yes
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much