473,657 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does that RegExp makes sense to you, people?

Hi,
I am trying to write a regexp to find all the code on the header of
entities in SQL Server (views, SPs, etc...) I got something like this:

(.|\n)*((create view)|(create proc)|(create function)|(crea te
trigger))

does that means sense? I want all the code that's before the code
header. now, the problem is, when i give that pattern with some string
buffer to the 'replace' method (I replace it with String.Empty...
meaning i want to remove the header) the whole enviroment just
freezes... the RegExp.Replace method never returns...

anybody has any idea why? or some different regexp that does the same
that may not hit that bug? (i assume its a bug) i am using .net 2.0

thanks
Jonathan

May 7 '07 #1
5 1279
have a look at regexlib.com, you can test and write your expression there.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
<yo**@nobhillso ft.comwrote in message
news:11******** *************@u 30g2000hsc.goog legroups.com...
Hi,
I am trying to write a regexp to find all the code on the header of
entities in SQL Server (views, SPs, etc...) I got something like this:

(.|\n)*((create view)|(create proc)|(create function)|(crea te
trigger))

does that means sense? I want all the code that's before the code
header. now, the problem is, when i give that pattern with some string
buffer to the 'replace' method (I replace it with String.Empty...
meaning i want to remove the header) the whole enviroment just
freezes... the RegExp.Replace method never returns...

anybody has any idea why? or some different regexp that does the same
that may not hit that bug? (i assume its a bug) i am using .net 2.0

thanks
Jonathan

May 7 '07 #2
Thanks Alvin,
I'll have a look. but whatever the expresion is, why would .net freeze
on me?

May 8 '07 #3
and oh... it freezes there just the same :) all it is is a web page
that calls the same methods i call... so not much value in it for me
right now. my question still stands....

thanks
Joanthan

May 8 '07 #4
Is this the exact expression, I don't have a freeze on my machine. Maybe
post some complete code that reproduces the error?

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
<yo**@nobhillso ft.comwrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
Thanks Alvin,
I'll have a look. but whatever the expresion is, why would .net freeze
on me?

May 8 '07 #5
* yo**@nobhillsof t.com wrote, On 7-5-2007 21:00:
Hi,
I am trying to write a regexp to find all the code on the header of
entities in SQL Server (views, SPs, etc...) I got something like this:

(.|\n)*((create view)|(create proc)|(create function)|(crea te
trigger))

does that means sense? I want all the code that's before the code
header. now, the problem is, when i give that pattern with some string
buffer to the 'replace' method (I replace it with String.Empty...
meaning i want to remove the header) the whole enviroment just
freezes... the RegExp.Replace method never returns...

anybody has any idea why? or some different regexp that does the same
that may not hit that bug? (i assume its a bug) i am using .net 2.0

thanks
Jonathan
If your input buffer is large enough, (.|\n)* will capture the complete
input first, and then the regex engine will start backtracking. This
takes an enormous amount of both memory and processing power.

You could try the following:

..*?

And add the following RegexOption to your call: RegexOption.Sin gleLine

SingleLine tells the parser to let . match all characters including the
newline. The extra ? at the end tells the parser to evaluate what's
behind the ? on every character and prevents the engine from having to
backtrack too much.

If you're very sure all the code before the header will always start at
the beginning of the input buffer (makes sense to me), fixing your regex
to the start of the string should also improve performance quite a bit:

^.*?(create ((view)|(proc)| (function)|(tri gger)))

Jesse
May 14 '07 #6

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

Similar topics

2
2555
by: Patryk Konieczka | last post by:
Hello Here's the thing I have a database edited by some company workers editing descriptions of books in the sotre , unfortunately these workers do not have the habit of inserting a space character after word-ending dot, this is why i use the function: function getCorrect($txt) { $txt=str_replace(",",", ",$txt); $txt=str_replace(".",". ",$txt);
10
7682
by: Andrew DeFaria | last post by:
I was reading my O'Reilly JavaScript The Definitive Guide when I came across RegExp and thought I could tighten up my JavaScript code that checks for a valid email address. Why does the following not appear to work: var email_address = "Joe@Schmoe"; var email_regex = new RegExp ("^(\\w+)(\@)(\\w+)(\.)(\\w+)$"); var result = email_regex.exec (email_address); alert (" result = \"" + result + "\"\n" + " result = \"" + result + "\"\n" + "...
14
4840
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it can be done using the designer but I intentionally don't want to use that. The one reason is that you cannot change the code generated by the designer. The other could be that you have more free hand and control to design your GUI. 2....
11
2920
by: HopfZ | last post by:
I coudn't understand some behavior of RegExp.test function. Example html code: ---------------- <html><head></head><body><script type="text/javascript"> var r = /^https?:\/\//g; document.write( ); </script></body></html> ---------------------
130
6526
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places in the database show up with *15* decimal places and are ever so slightly off (in the example in the subject line, by about 2E-15). I'm not doing any operations on this column. It's just running a stored procedure which performs a pretty basic...
71
10723
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or is that automatic? Thanks
65
3573
by: Aditya | last post by:
Hi I am using a line of as char recvedValues = {'\0'}; in my code. I get a warning as near initialization for recvedValues. I am using gcc 3.4 Can anybody please explain the meaning. Thanks Aditya
2
11675
by: X l e c t r i c | last post by:
Here: http://bigbangfodder.fileave.com/res/sandr.html I'm trying to use string.replace() for a basic search and replace form using textarea values as the regexp and replacement values for string.replace(). When I tried to use the textarea variable name for regexp it didn't work as I thought it would. For example:
3
2991
by: james.kirin40 | last post by:
Hi everyone, I am using Python's re module to extract some data from html. The following code never returns, and I was wondering if someone can explain to me why. Is this a problem with my regexp (I tried really hard to find it?)? The string contains three records (list items in a html page). Notice that NONE of them matches the regexp: these records do not contain the "title" element which the regexp expects inside '<span
0
8315
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
8734
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
8508
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
7341
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, and deployment—without 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
6172
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
5633
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();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.