473,802 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using regular expressions in code generation or regeneration

Please look at this code fragment:

#region Custom Code - Generated_Metho ds
// Generated_Discu ssion_Methods
public abstract IDataReader GetDiscussion() ;
public abstract void DeleteDiscussio n(int itemID);
#endregion // Custom Code - Generated_Metho ds

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

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

// Custom_Discussi on_Methods

I want to achieve 2 things with regular expressions:

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

// Generated_NEWCL ASS_Methods
public abstract IDataReader GetNEWCLASS();
public abstract void DeleteNEWCLASS( int itemID);
to just before line:
#endregion // Custom Code - Generated_Metho ds
(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_NEWCL ASS_Methods
public abstract IDataReader GetNEWCLASS();
public abstract void DeleteNEWCLASS( int itemID);
I have this segment (let's call it REPLACING_SEGME NT):

// Generated_Discu ssion_Methods
public abstract IDataReader GetDiscussion(i nt ID);
public abstract void DeleteDiscussio nNew(int itemID, bool Confirm);
public abstract void DeleteDiscussio n(int itemID);

I want the corresponding segment between:
#region Custom Code - Generated_Metho ds
and
#endregion // Custom Code - Generated_Metho ds
(let's call it REPLACED_SEGMEN T):
public abstract IDataReader GetDiscussion() ;
public abstract void DeleteDiscussio n(int itemID);
to be replaced with REPLACING_SEGME NT.
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_Metho ds
and
#endregion // Custom Code - Generated_Metho ds
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 1066

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

Similar topics

2
2369
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 uppercase or lowercase, and all other characters being lowercase characters. The difficult part is that I want to obtain save the string positions of the invalid characters in an array, rather than just obtain a true or false value. Can anybody...
8
2433
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: 0.04, 0.02, 0.01" how can I extract this number with RE or otherwise?
1
2056
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 certain pattern.”. I e.g. want to extract everything between “expressions” and “a” which is in the above example “are often used to make sure that”. The unfortunately best I could do was the following piece of code: Dim...
4
5187
by: Egyd 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 adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
1
10069
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. This program can perform 5 options from a menu on your POP3 mail by logging in with the correct POP3 server along with a user name and password that you use to log in to your ISP. The user name and password as well as the server name are all hard-coded...
20
2377
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 code is problematic, and i was wondering if someone who know about regular expressions really well could have a look at it and tell me what is the problem. function checkform ( form ) { if (!/+$/.test(form.name.value)) { alert( "Please...
0
1959
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 of string manipulation where they seek through the string back and forth doing replacements to substitute in the needed HTML code. I am convinced that this can be done with a few regular expressions. Unfortunately my knowledge of regular...
1
4388
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 the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
6
3519
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 the string: "AAANN" it would return a string containing 3 alphanumeric characters followed by 3 digits. This part I have managed:) I would now like to add some complexity to this, such as repetitions and grouping. For example, I'd like to have...
0
9562
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
10538
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
10305
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...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
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
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.