Hi,
I'm using regular expressions to extract some information from my
vb.net source code files.
I have something like this:
1: '<class name="xyz" description="xx xxxx"/>
2: Class xyz
... other lines of code ...
y: End Class
I want to extract with regular expression a string that contains the
file from line 1 to line y. To do this I use the following regular
expression pattern:
'\s*<class.*End \s+Class
But it doesn't work, it returns zero matches. I tried to set the
IgnoreCase flag, the MultiLine flag, but there is nothing to do. Note
that if I use the following pattern:
'\s*<class.*/>
to extract only line 1 it works.
So it seems that the .* (It should match all characters between
'<Class and End Class) doesn't work when there are multiple lines.
What can I do?
Thanks in advance for the help.
Bye
Gianluca 3 1407
1. You need the Singleline-Flag, or the '.' character won't match newlines
2. Use something like: "\bclass\b.*\bE nd\s+Class\b" "\b" ensures word
boundary
3. This won't work with nested classes, or more than one class in per file
4. This won't recognize comments or strings - If your code contains a string
literal "end class" or a comment ' end class, the regex will think this is
the end of the class.
Correct handling of these cases is possible, but quite complex: If you need
this, maybe a parsing the file line-by-line would be easier.
Niki
"Gianluca" <mo**********@h otmail.com> wrote in
news:56******** *************** ***@posting.goo gle.com... Hi,
I'm using regular expressions to extract some information from my vb.net source code files.
I have something like this:
1: '<class name="xyz" description="xx xxxx"/> 2: Class xyz ... other lines of code ... y: End Class
I want to extract with regular expression a string that contains the file from line 1 to line y. To do this I use the following regular expression pattern:
'\s*<class.*End \s+Class
But it doesn't work, it returns zero matches. I tried to set the IgnoreCase flag, the MultiLine flag, but there is nothing to do. Note that if I use the following pattern:
'\s*<class.*/>
to extract only line 1 it works. So it seems that the .* (It should match all characters between '<Class and End Class) doesn't work when there are multiple lines.
What can I do?
Thanks in advance for the help.
Bye
Gianluca
Niki,
I wrote 10 minutes ago in the general group I did not see messages from you
some days, a mistake I see.
Cor
"Niki Estner" <ni*********@cu be.net> wrote in message news:<#6******* ******@TK2MSFTN GP09.phx.gbl>.. .
You are right, setting the Singleline flag it works.
I thought that this flag was the default, that is the reason why I
didn't tried this flag before.
Thanks for your suggestions.
Bye
Gianluca 1. You need the Singleline-Flag, or the '.' character won't match newlines 2. Use something like: "\bclass\b.*\bE nd\s+Class\b" "\b" ensures word boundary 3. This won't work with nested classes, or more than one class in per file 4. This won't recognize comments or strings - If your code contains a string literal "end class" or a comment ' end class, the regex will think this is the end of the class.
Correct handling of these cases is possible, but quite complex: If you need this, maybe a parsing the file line-by-line would be easier.
Niki
"Gianluca" <mo**********@h otmail.com> wrote in news:56******** *************** ***@posting.goo gle.com... Hi,
I'm using regular expressions to extract some information from my vb.net source code files.
I have something like this:
1: '<class name="xyz" description="xx xxxx"/> 2: Class xyz ... other lines of code ... y: End Class
I want to extract with regular expression a string that contains the file from line 1 to line y. To do this I use the following regular expression pattern:
'\s*<class.*End \s+Class
But it doesn't work, it returns zero matches. I tried to set the IgnoreCase flag, the MultiLine flag, but there is nothing to do. Note that if I use the following pattern:
'\s*<class.*/>
to extract only line 1 it works. So it seems that the .* (It should match all characters between '<Class and End Class) doesn't work when there are multiple lines.
What can I do?
Thanks in advance for the help.
Bye
Gianluca This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 regular expressions
easier to create and use (and in my experience as a regular expression
user, it makes them MUCH easier to create and use.)
I'm still working on formal documentation, and in any case, such
documentation isn't necessarily the...
|
by: Sehboo |
last post by:
Hi,
I have several regular expressions that I need to run against
documents. Is it possible to combine several expressions in one
expression in Regex object. So that it is faster, or will I have to
use all the expressions seperately?
Here are my regular expressions that check for valid email address and
link
Dim Expression As String =
|
by: Greg Vereschagin |
last post by:
I'm trying to figure out a regular expression that will match the
innermost tag and the contents in between. Specifically, the string
that I am attempting to match looks as follows:
....<table>...<table>...>Final<...</table>...</table>...
I want to match: <table>...>Final<...</table> from this example.
The string could also, of course, look like the following:
|
by: Kijak |
last post by:
Hi,
Im just starting working with REGEX and got a few problems. Could you
tell me how to test if two strings can be found in another. ei:
String to test: "This is a great car you got"
Look for: "great" AND "car"
and what about upper case
|
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 adate LIKE "2004.01.10 __:15")
....
into something like this:
.... where adate LIKE "2004.01.10 __:(30/15)" ...
| |
by: a |
last post by:
I'm a newbie needing to use some Regular Expressions in PHP.
Can I safely use the results of my tests using 'The Regex Coach'
(http://www.weitz.de/regex-coach/index.html)
Are the Regular Expressions used in Perl identical to the Regular
Expressions in PHP?
|
by: =?Utf-8?B?Y3VyaW91cw==?= |
last post by:
I am using a RegularExpressionValidator to validate a TextBox. I use
"^?+(\.*)?$" to check for a real number. The control works
fine as long as the user enters something in the TextBox; it does not work if
the user leaves the TextBox blank. Is there a bug in the implementation of
the RegularExpressionValidator? The above regluar expression should also
catch no entry by the user.
I have added a RequiredFieldValidator to solve the...
|
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...
|
by: Wiseman |
last post by:
I'm kind of disappointed with the re regular expressions module. In
particular, the lack of support for recursion ( (?R) or (?n) ) is a
major drawback to me. There are so many great things that can be
accomplished with regular expressions this way, such as validating a
mathematical expression or parsing a language with nested parens,
quoting or expressions.
Another feature I'm missing is once-only subpatterns and possessive
quantifiers...
|
by: FAQEditor |
last post by:
Anybody have any URL's to tutorials and/or references for Regular
Expressions?
The four I have so far are:
http://docs.sun.com/source/816-6408-10/regexp.htm
http://en.wikipedia.org/wiki/Regular_expression
http://www.regular-expressions.info/javascript.html
http://www.webreference.com/js/column5/
|
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,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |