473,383 Members | 1,870 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,383 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 5070
> 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 "":...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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...

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.