Regex string remplace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erakis

    Regex string remplace

    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(myS tring,
    "<span...") ;

    Thank for your help


  • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

    #2
    Re: Regex string remplace

    Erakis wrote:
    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(myS tring,
    "<span...") ;
    Why do you need regex ?

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

    Arne

    Comment

    Working...