473,657 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does Regex work?

I tried

Dim s As String = "1 2 3 4 5"

Regex.Replace(s , "3", "6")

but no luck, nothing was changed?
Nov 21 '05 #1
9 1342
<Lucio H> schrieb:
I tried

Dim s As String = "1 2 3 4 5"

Regex.Replace(s , "3", "6")


\\\
s = Regex.Replace(s , "3", "6")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
This was driving me crazy, thanks!!!
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:OS******** ******@TK2MSFTN GP14.phx.gbl...
<Lucio H> schrieb:
I tried

Dim s As String = "1 2 3 4 5"

Regex.Replace(s , "3", "6")


\\\
s = Regex.Replace(s , "3", "6")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Lucio,

Why not just
Dim s As String = "1 2 3 4 5"

Regex.Replace(s , "3", "6")

s = Replace("3","6" ) it will not be a big time benefit, however there will
be probably a time benefit and describes in my idea at least better what you
want that the program does.

Just my idea

Cor
Nov 21 '05 #4
Hi Cor, the reason is that I was not really interested in the substitution
per se, I wanted to know how regex works, I am sure you are not
suggesting regex is an unusfull tool...

tnx.
--

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uz******** ******@TK2MSFTN GP09.phx.gbl...
Lucio,

Why not just
Dim s As String = "1 2 3 4 5"

Regex.Replace(s , "3", "6")

s = Replace("3","6" ) it will not be a big time benefit, however there will
be probably a time benefit and describes in my idea at least better what
you want that the program does.

Just my idea

Cor

Nov 21 '05 #5
<Lucio H> wrote in news:eA******** *****@TK2MSFTNG P15.phx.gbl:
Hi Cor, the reason is that I was not really interested in the
substitution per se, I wanted to know how regex works, I am sure you
are not suggesting regex is an unusfull tool...


Ancient PERL proverb...

If you have a problem and require a regex to solve it, you now have two
problems.
All the best

Tim F

Nov 21 '05 #6
Lucio,
Hi Cor, the reason is that I was not really interested in the substitution
per se, I wanted to know how regex works, I am sure you are not
suggesting regex is an unusfull tool...

No in general not, however for the sample from you it is.

It is useful there where the change is complex.

Cor
Nov 21 '05 #7
It seems regular expressions where easier in vi and perl, though
they didn't have unicode to contend with...
regex- i love it !!

"Tim Ferguson" <Fe********@sof thome.net> wrote in message
news:Xn******** *************** ******@207.46.2 48.16...
<Lucio H> wrote in news:eA******** *****@TK2MSFTNG P15.phx.gbl:
Hi Cor, the reason is that I was not really interested in the
substitution per se, I wanted to know how regex works, I am sure you
are not suggesting regex is an unusfull tool...


Ancient PERL proverb...

If you have a problem and require a regex to solve it, you now have two
problems.
All the best

Tim F

Nov 21 '05 #8
Lucio,

I forgot to give you some good links for regex.

RegexLib
http://www.regexlib.com/Default.aspx

Expresso
http://www.ultrapico.com/Expresso.htm
I hope this helps a little bit?

Cor
Nov 21 '05 #9
Thank you Cor, you have read my mind.
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:uD******** ******@TK2MSFTN GP14.phx.gbl...
Lucio,

I forgot to give you some good links for regex.

RegexLib
http://www.regexlib.com/Default.aspx

Expresso
http://www.ultrapico.com/Expresso.htm
I hope this helps a little bit?

Cor

Nov 21 '05 #10

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

Similar topics

16
2152
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at RegEx.IsMatch but it behaves quite differently. Is there a way I can mimic the DOS filtering of filenames (eg. "*.*" or "*" returns all files, "*.xls" returns all excel files, "workbook*" returns all files begining with "workbook" etc)? thanks in...
1
5338
by: Ada | last post by:
i'm trying to use Regex to match a 4 number group pattern. once a match is found, write it to RichTextBox in red. test data: This is my 4567 test data. 1234this is another line of data. Here's two more 9876 5432. What a headache!!!
7
2609
by: bill tie | last post by:
I'd appreciate it if you could advise. 1. How do I replace "\" (backslash) with anything? 2. Suppose I want to replace (a) every occurrence of characters "a", "b", "c", "d" with "x", (b) every occurrence of characters "p", "q", "r", "s" with "y". Right now, I do it as follows:
6
1770
by: tshad | last post by:
Is there a way to use Regex inside of a tag, such as asp:label? I tried something like this but can't make it work: <asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/> I have this inside my Repeater and want it to filter the field during bind. I can do it afterwards by just looping through the repeater items, but that is extra work and time.
8
1820
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the string contains two plus signs "+". Should this be a seperate RegEx or can one RegEx check for both signs? Thanks!
6
2494
by: Extremest | last post by:
I have a huge regex setup going on. If I don't do each one by itself instead of all in one it won't work for. Also would like to know if there is a faster way tried to use string.replace with all the right parts in there in one big line and for some reason that did not work either. Here is my regex's. static Regex rar = new Regex("\\.part.*", RegexOptions.IgnoreCase); static Regex par = new Regex("\\.vol.*", RegexOptions.IgnoreCase);
7
2580
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward slash then some numbers. For some reason I am not getting that. It won't work at all in 2.0
3
1857
by: Efi | last post by:
Hello, I am trying to capture empty lines, for example : 1. ABCDEF 2. 3. abcdef I would like to capture line number 2. I am using the following regex - new Regex("^$",RegexOptions.Multiline);
1
1158
by: TtfnJohn | last post by:
I have two small scripts that while on the surface should both work the problem is they don't. Here's the first one: import re testString = 'Thap,fpvi,*!wtyd@*.dip.t-dialin.net:*!ylx@*.dip.t- dialin.net:*!lajaz@*.dip.t-dialin.net::::::' reobj = re.compile(r"(.*),(.*),(.*):::(.*):::(.*)")
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2745
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 we have to send another system
2
1736
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.