473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Regexp.Replace Problem

content=Regex.Replace(content, @"/*Offline*/", @"//Offline");
content=Regex.Replace(content, @"//Online", @"/*Online*/");

Second line works fine but the first didn't!
I think the problem are the "*" in the first line.
Is it a bug?
Nov 15 '05 #1
2 4380
KennethSoona <ke***********@gmx.net> wrote:
content=Regex.Replace(content, @"/*Offline*/", @"//Offline");
content=Regex.Replace(content, @"//Online", @"/*Online*/");

Second line works fine but the first didn't!
I think the problem are the "*" in the first line.
Yup.
Is it a bug?


Yes, but in your code rather than the regex code :) It's because * is a
special character in regular expressions. Try:

content=Regex.Replace(content, @"/\*Offline\*/", "//Offline");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2
KennethSoona <ke***********@gmx.net> wrote:
content=Regex.Replace(content, @"/*Offline*/", @"//Offline");
content=Regex.Replace(content, @"//Online", @"/*Online*/");

Second line works fine but the first didn't!
I think the problem are the "*" in the first line.
Yup.
Is it a bug?


Yes, but in your code rather than the regex code :) It's because * is a
special character in regular expressions. Try:

content=Regex.Replace(content, @"/\*Offline\*/", "//Offline");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3

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

Similar topics

4
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning...
19
by: Dr Clue | last post by:
I'm not really an expert with RegExp() , although I do use it. The problem I have is that I want to strip comments out of a CSS file using RegExp() The reason is that I'm loading and parsing to...
1
by: eysteinbye | last post by:
I have a problem with my RegExp. I need to replace some URLs with other URLs. I am using a URL-rewrite filter). The problem is that when the RegExp match just parts of the string, it does a...
4
by: Jon Maz | last post by:
Hi All, I want to strip the accents off characters in a string so that, for example, the (Spanish) word "práctico" comes out as "practico" - but ignoring case, so that "PRÁCTICO" comes out as...
2
by: Bill McCormick | last post by:
Hello, I'm new to VB.NET but have used regexp in Perl and VI. I'd like to read a regular expression from a file and apply it to a string read from another file. The regexp is simple word...
13
by: Phat G5 (G3) | last post by:
I am weak when it comes to regexp but hoped someone might know in this case. I am trying to take a url like this : something.lasso?blah=blah&blah2=blah2&sort=hello&blah3=blah3 And remove the...
7
by: Csaba Gabor | last post by:
I need to come up with a function function regExpPos (text, re, parenNum) { ... } that will return the position within text of RegExp.$parenNum if there is a match, and -1 otherwise. For...
3
by: yoni | last post by:
Hi, I am trying to write a regexp to find all the code on the header of entities in SQL Server (views, SPs, etc...) I got something like this: (.|\n)*((create view)|(create proc)|(create...
2
by: X l e c t r i c | last post by:
Here: http://bigbangfodder.fileave.com/res/sandr.html I'm trying to use string.replace() for a basic search and replace form using textarea values as the regexp and replacement values for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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
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,...

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.