Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

use regular expression to change text

Posted on 2014-03-07
6
Medium Priority
?
378 Views
Last Modified: 2014-03-07
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,
0
Comment
Question by:ethar1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39912865
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

0
 

Author Comment

by:ethar1
ID: 39912880
Thanks for your reply,
I am using c# VS 2013
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39912917
So the replacement is taking place via C# code, using the Regex class?
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:ethar1
ID: 39912927
yes
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39912935
OK, then the above should work. The code would look like this:

string result = Regex.Replace(original, "<meaning>([^<]+)</meaning>", "<meaning text=\"$1\" TextAR=\"\" />");

Open in new window

0
 

Author Closing Comment

by:ethar1
ID: 39913076
Thank you very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question