Regular Expression

  • Thread starter Juan Gabriel Del Cid
  • Start date
J

Juan Gabriel Del Cid

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
 
B

Buddy

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
 
J

Jeffrey Tan[MSFT]

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" <[email protected]>
| 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: <[email protected]>
| 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
|
|
|
 
B

Buddy

Thanks for the reply Jeffrey, I only want to know what's
the Regular Expression parttern?

Thanks,
 
J

Jeffrey Tan[MSFT]

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/default.asp?url=/library/en-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/default.asp?url=/library/en-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: "(e-mail address removed)" <[email protected]>
| Sender: "(e-mail address removed)" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Regular Expression
| Date: Sat, 25 Oct 2003 05:30:30 -0700
| Lines: 70
| Message-ID: <[email protected]>
| 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" <[email protected]>
| >| 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: <[email protected]>
| >| 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
| >|
| >|
| >|
| >
| >.
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top