473,395 Members | 1,885 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,395 software developers and data experts.

Regular Expression

Can someone please show me how to create a regular expression to do the
following

My text is set to
[vbl] MyColumn{1, 100} Test

I want a regular expression that sets the text to the following
[vbl] testMyColumn{1, 100}Test

Basically I want the regular expression to add the word test infront of the
word MyColumn and also remove 4 spaces after } and the word Test.

Thanks
Nov 15 '05 #1
4 5080
> My text is set to
[vbl] MyColumn{1, 100} Test

I want a regular expression that sets the text to the following
[vbl] testMyColumn{1, 100}Test


The pattern is:

string pattern = @"(\[vbl] )(MyColumn\{\d+, \d+\})(\s+)(Test)";

and you should use a MatchEvaluator that returns the propper string.

Hope that helps,
-JG
Nov 15 '05 #2

Hi Buddy,

I think you can do something like this:

string str="[vbl] MyColumn{1, 100} Test";
Regex rg1=new Regex("\\s{4}");
string [] collection=rg1.Split(str);
Regex rg2=new Regex("My");
string new1=rg2.Replace(collection[0],collection[1].ToLower());
string new2=new1+collection[1];
MessageBox.Show(new2);

Hope this helps,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Buddy" <Bu***@onlinehome.com>
| Subject: Regular Expression
| Date: Fri, 24 Oct 2003 23:18:50 +0100
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <uw*************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 81-1-69-6.homechoice.co.uk 81.1.69.6
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:193940
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Can someone please show me how to create a regular expression to do the
| following
|
| My text is set to
| [vbl] MyColumn{1, 100} Test
|
| I want a regular expression that sets the text to the following
| [vbl] testMyColumn{1, 100}Test
|
| Basically I want the regular expression to add the word test infront of
the
| word MyColumn and also remove 4 spaces after } and the word Test.
|
| Thanks
|
|
|

Nov 15 '05 #3
Thanks for the reply Jeffrey, I only want to know what's
the Regular Expression parttern?

Thanks,
-----Original Message-----

Hi Buddy,

I think you can do something like this:

string str="[vbl] MyColumn{1, 100} Test";
Regex rg1=new Regex("\\s{4}");
string [] collection=rg1.Split(str);
Regex rg2=new Regex("My");
string new1=rg2.Replace(collection[0],collection [1].ToLower());string new2=new1+collection[1];
MessageBox.Show(new2);

Hope this helps,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| From: "Buddy" <Bu***@onlinehome.com>
| Subject: Regular Expression
| Date: Fri, 24 Oct 2003 23:18:50 +0100
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165| Message-ID: <uw*************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 81-1-69-6.homechoice.co.uk 81.1.69.6
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl! tk2msftngp13.phx.gbl| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:193940| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Can someone please show me how to create a regular expression to do the| following
|
| My text is set to
| [vbl] MyColumn{1, 100} Test
|
| I want a regular expression that sets the text to the following| [vbl] testMyColumn{1, 100}Test
|
| Basically I want the regular expression to add the word test infront ofthe
| word MyColumn and also remove 4 spaces after } and the word Test.|
| Thanks
|
|
|

.

Nov 15 '05 #4

Hi Buddy,

Net Framework provides System.Text.RegularExpressions namespace for us to
work with Regular Expression.
You can get a simple general introduction of ".NET Framework Regular
Expressions" at the link below:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcomregularexpressions.asp

But if you want to get a detailed reference of it, you can refer to the
JScript .NET's "Regular Expression Syntax" section, link:
http://msdn.microsoft.com/library/de...us/jscript7/ht
ml/jsreconbackreferences.asp

Finally, there is a web site special for Regular Expression, you can get a
tutorial from it at:
http://www.regular-expressions.info/tutorial.html

If I misunderstand your meanning, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Bu***@Onlinehome.com" <an*******@discussions.microsoft.com>
| Sender: "Bu***@Onlinehome.com" <an*******@discussions.microsoft.com>
| References: <uw*************@tk2msftngp13.phx.gbl>
<sS*************@cpmsftngxa06.phx.gbl>
| Subject: RE: Regular Expression
| Date: Sat, 25 Oct 2003 05:30:30 -0700
| Lines: 70
| Message-ID: <02****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOa88b1uu7kg/nXT9Oyh6bxrarHfQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:194005
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks for the reply Jeffrey, I only want to know what's
| the Regular Expression parttern?
|
| Thanks,
|
| >-----Original Message-----
| >
| >Hi Buddy,
| >
| >I think you can do something like this:
| >
| >string str="[vbl] MyColumn{1, 100} Test";
| >Regex rg1=new Regex("\\s{4}");
| >string [] collection=rg1.Split(str);
| >Regex rg2=new Regex("My");
| >string new1=rg2.Replace(collection[0],collection
| [1].ToLower());
| >string new2=new1+collection[1];
| >MessageBox.Show(new2);
| >
| >Hope this helps,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| From: "Buddy" <Bu***@onlinehome.com>
| >| Subject: Regular Expression
| >| Date: Fri, 24 Oct 2003 23:18:50 +0100
| >| Lines: 15
| >| X-Priority: 3
| >| X-MSMail-Priority: Normal
| >| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V6.00.2800.1165
| >| Message-ID: <uw*************@tk2msftngp13.phx.gbl>
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| NNTP-Posting-Host: 81-1-69-6.homechoice.co.uk 81.1.69.6
| >| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| tk2msftngp13.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:193940
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| Can someone please show me how to create a regular
| expression to do the
| >| following
| >|
| >| My text is set to
| >| [vbl] MyColumn{1, 100} Test
| >|
| >| I want a regular expression that sets the text to the
| following
| >| [vbl] testMyColumn{1, 100}Test
| >|
| >| Basically I want the regular expression to add the
| word test infront of
| >the
| >| word MyColumn and also remove 4 spaces after } and the
| word Test.
| >|
| >| Thanks
| >|
| >|
| >|
| >
| >.
| >
|

Nov 15 '05 #5

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

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
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: 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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
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,...

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.