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

Using regular expressions in code generation or regeneration

Please look at this code fragment:

#region Custom Code - Generated_Methods
// Generated_Discussion_Methods
public abstract IDataReader GetDiscussion();
public abstract void DeleteDiscussion(int itemID);
#endregion // Custom Code - Generated_Methods

// Generated_NEWCLASS_Methods
public abstract IDataReader GetNEWCLASS();
public abstract void DeleteNEWCLASS(int itemID);

#region Custom Code - Custom_Methods #1
#endregion // Custom Code - Custom_Methods #1

// Custom_Discussion_Methods

I want to achieve 2 things with regular expressions:

FIRST THING: I want to move segment (blank line counts):

// Generated_NEWCLASS_Methods
public abstract IDataReader GetNEWCLASS();
public abstract void DeleteNEWCLASS(int itemID);
to just before line:
#endregion // Custom Code - Generated_Methods
(I BELIEVE STEPS ARE: Find the segment (to be moved) boundaries, copy
it to a variable, replace segment boundaries with empty string and
insert saved text just before: #endregion // Custom Code -
Custom_Methods #1 line")

SECOND THING (this is independent case of the first): If instead of
segment:

// Generated_NEWCLASS_Methods
public abstract IDataReader GetNEWCLASS();
public abstract void DeleteNEWCLASS(int itemID);
I have this segment (let's call it REPLACING_SEGMENT):

// Generated_Discussion_Methods
public abstract IDataReader GetDiscussion(int ID);
public abstract void DeleteDiscussionNew(int itemID, bool Confirm);
public abstract void DeleteDiscussion(int itemID);

I want the corresponding segment between:
#region Custom Code - Generated_Methods
and
#endregion // Custom Code - Generated_Methods
(let's call it REPLACED_SEGMENT):
public abstract IDataReader GetDiscussion();
public abstract void DeleteDiscussion(int itemID);
to be replaced with REPLACING_SEGMENT.
Effectively I want to do code (re)generation where I would like to add
new code segments to existing code (that is preserved using "preserve"
delimiters:
#region Custom Code - Generated_Methods
and
#endregion // Custom Code - Generated_Methods
regions) and later allow for replacing previously generated segment
(which had been moved to "preserve" delimiters I mentioned above in one
of previous generation of code) during regeneration.

Any help would be appreciated.
Rad

Nov 16 '05 #1
0 1046

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

Similar topics

2
by: Ron Brennan | last post by:
Good morning. I would like to use one or more RegExp to validate country names as having the first and last words beginning with an uppercase letter, intermediate words beginning with either...
8
by: Michael McGarry | last post by:
Hi, I am horrible with Regular Expressions, can anyone recommend a book on it? Also I am trying to parse the following string to extract the number after load average. ".... load average:...
1
by: Daniel Walzenbach | last post by:
Hi, does anybody know I can extract a substring of a text with regular expressions. Let’s consider the following text: “Regular expressions are often used to make sure that a string matches a...
4
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
20
chunk1978
by: chunk1978 | last post by:
hi everyone... i'm preparing to complete a validated form through client-side javascript with regular expressions... and yes the form will also be validated server-side as well... anyway, my regex...
0
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use...
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...
6
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.