473,405 Members | 2,262 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,405 software developers and data experts.

Replace using Regular Expressions

Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "", RegexOptions.IgnorePatternWhitespace);

in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do not
know how to take code for replace from it.
Nov 17 '05 #1
6 1774
To simple delete all dots in a String, you might find it easier using the
String.Replace method:
string result = theString.Replace(".", string.Empty);

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Vlado B." <vl***********@sk.htnet.hr> wrote in message
news:d4**********@ss405.t-com.hr...
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "",
RegexOptions.IgnorePatternWhitespace);

in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do
not
know how to take code for replace from it.

Nov 17 '05 #2
you mean
theString = Regex.Replace(theString, @"[.]+", "",
RegexOptions.IgnorePatternWhitespace);

right?
;-)

Vlado B. wrote:
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "", RegexOptions.IgnorePatternWhitespace);

in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do not
know how to take code for replace from it.

Nov 17 '05 #3
In message <d4**********@ss405.t-com.hr>, Vlado B.
<vl***********@sk.htnet.hr> writes
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "", RegexOptions.IgnorePatternWhitespace);

in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?


@"\.*"?

"." without the escape matches any character.

--
Steve Walker
Nov 17 '05 #4
No, I ment what I wrote and I admit I was wrong.
I don't know why have I thought that Regex.Replace automatically changes the
given string!?

Thank you very much, now it works just perfect.

Vlado
"Uri Dor" <ta****@newsgroups.nospam> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
you mean
theString = Regex.Replace(theString, @"[.]+", "",
RegexOptions.IgnorePatternWhitespace);

right?
;-)

Vlado B. wrote:
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "", RegexOptions.IgnorePatternWhitespace);
in other words delete every occurrence of one or more dots in some string. It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do not know how to take code for replace from it.

Nov 17 '05 #5
since RegEx.Replace doesn't modify the string but instead returns a new one
you have to:

theString = Regex.Replace(theString, @"[.]+", "",
RegexOptions.IgnorePatternWhitespace);
"Vlado B." <vl***********@sk.htnet.hr> schrieb im Newsbeitrag
news:d4**********@ss405.t-com.hr...
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "", RegexOptions.IgnorePatternWhitespace);
in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do not know how to take code for replace from it.

Nov 17 '05 #6
Yeah,I agree.This just because it is more efficient to use the
String.Replace method.

"Dennis Myrén" wrote:
To simple delete all dots in a String, you might find it easier using the
String.Replace method:
string result = theString.Replace(".", string.Empty);

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Vlado B." <vl***********@sk.htnet.hr> wrote in message
news:d4**********@ss405.t-com.hr...
Hi everyone
I have tried something like this

Regex.Replace(theString, @"[.]+", "",
RegexOptions.IgnorePatternWhitespace);

in other words delete every occurrence of one or more dots in some string.
It does not work.
Does anyone know what am I doing wrong?

TIA
Vlado

P.S. I also tried the expression in Expresso and it works there but I do
not
know how to take code for replace from it.


Nov 17 '05 #7

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

Similar topics

4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
24
by: Wim Roffal | last post by:
Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg. Wim
16
by: Stephane | last post by:
Hi, I'm trying to replace parenthesis using Regex.replace but I'm always having this error: System.ArgumentException: parsing ":-)" - Too many )'s. Parameter name: :-) Here's my code: ...
18
by: Jon S via DotNetMonster.com | last post by:
Hi all, I searching a string to see if "Desc" resides in it, if so then replace it with "Description". For some reason if it finds "Desc" in the word "Description" it replaces the "Desc" part...
6
by: Chris Anderson | last post by:
Anyone know of a fix (ideally) or an easy workaround to the problem of escape characters not working in regex replacement text? They just come out as literal text For example, you'd think that thi...
4
by: JackRazz | last post by:
Could someone give me a very simple regular expression for Visual Studio's search/replace using backreferences saving portions of the match as \1 or $1 or whatever. I want to use something I can...
4
by: lucky | last post by:
hi there!! i'm looking for a code snipett wich help me to search some words into a particular string and replace with a perticular word. i got a huge data string in which searching traditional...
4
by: jgabbai | last post by:
Hi, What is the best way to white list a set of allowable characters using regex or replace? I understand it is safer to whitelist than to blacklist, but am not sure how to go about it. Many...
8
by: John Pye | last post by:
Hi all I have a file with a bunch of perl regular expressions like so: /(^|)\*(.*?)\*(|$)/$1'''$2'''$3/ # bold /(^|)\_\_(.*?)\_\_(|$)/$1''<b>$2<\/ b>''$3/ # italic bold...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.