473,498 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Really simple regex problem

Hello there.

This should be very simple for someone to solve.

string s = System.Text.RegularExpressions.Regex.Replace(
"King Henry Viii", "\bViii\b", "VIII");
Console.WriteLine(s);

I think the above code should write out the string "King Henry VIII"
(with capital I's), but instead it writes the original input string
unchanged. If I remove both (but not either) of the word boundary meta
characters then it works as expected. Could someone show me where I am
going wrong?

Cheers,

Mike

Nov 30 '06 #1
1 1204
The Regex is fine; the problem is the C# - specifically the character
escaping; just add @...

@"\bViii\b"

Marc

Nov 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1992
by: Leszek Dubiel | last post by:
----------------------------------------- BACKGROUND In my company (www.glass.biz) we use ERP software to compute what has to be done to do products for our customers. Main algorithm takes data...
4
9700
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
8084
by: live your lives | last post by:
i am trying to validate a simple username textbox using RegularExpressionValidator: TextBox tbUserName = new TextBox(); tbUserName.ID = "tbUserName"; string strPatternUserName = @"\W"; //...
18
3012
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
20
2527
by: Larry Woods | last post by:
I'm drawing a blank... What is the regular expression for search a string for NO occurances of a substring? Example: I want to find all lines that do NOT have the substing "image" in them. ...
2
1151
by: Brian Henry | last post by:
Hi everyone, I never have worked much with regex (trying to learn it now myself) but I have a simple problem that I need to solve.. Say I have numbers like this 00023432-234...
0
1603
by: Tom Shelton | last post by:
This is a simple example of a numeric only text box. It allows only the entry of integer values. The advantage of this example is that it also handles user attempts to past non integer text data...
2
3815
by: Thomas T. Veldhouse | last post by:
Hello. I have been working with a client of mine on their seriazation code and we seem to have run into an issue when we migrated from .NET 1.1 to .NET 2.0. We have a framework of business...
1
2137
by: Alan Patterson | last post by:
I have installed boost 1.33.1 and everything compiled and installed fine on Windows using Visual C++ 8.0. I wrote the following simple code to test the regex library and it doesn't seem to work....
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.