Regex string remplace

E

Erakis

Hi,

In this text :
*****************************************************************
MULTIPLE WARNINGS for ...

This is a beautiful day... but WARNING for...

WARNING is a word for ....
*****************************************************************

I would like to replace the all WARNING occurence by "<span
style="color :red;">WARNING</span>"
and WARNINGS occurences by "<span style="color :red;">WARNINGS</span>"

Here is what I did so far but it not seem to works :

string result = new Regex( @"/WARNING.*/g").Replace(myString,
"<span...");

Thank for your help
 
A

Arne Vajhøj

Erakis said:
In this text :
*****************************************************************
MULTIPLE WARNINGS for ...

This is a beautiful day... but WARNING for...

WARNING is a word for ....
*****************************************************************

I would like to replace the all WARNING occurence by "<span
style="color :red;">WARNING</span>"
and WARNINGS occurences by "<span style="color :red;">WARNINGS</span>"

Here is what I did so far but it not seem to works :

string result = new Regex( @"/WARNING.*/g").Replace(myString,
"<span...");

Why do you need regex ?

From what you have described it seems as if a simple String
Replace would do.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top