Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a string like this.

"THIS is a very STRANGE string"

I wanted to add span tag with color style around it like below

<span style='color:Blue;'>THIS</span> is a very <span style='color:Blue;'>STRANGE</span> string
i can do this by using split function and check isuppercase and insert.

But is there any reg expression or any other solution so that i can use simply like a one line code. if so help me out.
Posted
Updated 19-Dec-14 3:26am
v2

1 solution

RegEx      : "(\b[A-Z]+\b)" 
Replacement: "<span style='color:Blue;'>$1</span>"
Input      : "THIS is a very STRANGE string" 
Output     : <span style='color:Blue;'>THIS</span> is a very <span style='color:Blue;'>STRANGE</span> string
 
Share this answer
 
v2
Comments
Navin.Paruchuri 19-Dec-14 9:37am    
but it will add span tag for all words which have starting letter caps
PIEBALDconsult 19-Dec-14 9:38am    
I thought that was the requirement, then the coffee hit and I updated it.
Navin.Paruchuri 19-Dec-14 9:42am    
ohh.. thanks man it worked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900