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

Help with a Perl Regular Expression

Hi,

I'm hoping someone can help me come up with a regular expression that I need
to match the following.

I'm looking to match all occurances of format <word>.<word> in a string that
is not followed by the words AS. This is coming from an SQL select
statement.

Basically, I'm looking to match all the field names in an SQL select
statement that are not being aliased.

For example, in the following statement:

Select
payment_module.module_name as `alias.name`,
payment_module.module_description,
payment_module.is_enabled,
configuration.configuration_key,
configuration.configuration_value,
configuration.store_id as `alias.storeid`
I'm looking to match only:
payment_module.module_description
payment_module.is_enabled
configuration.configuration_key
configuration.configuration_value

Ideally, am looking for an expression using subexpressions that further
seperate the table name from the field name in this select statement:
ie: payment_module and module_description
payment_module and is_enabled
configuration and configuration_key
configuration and configuration_value
Any help would be greatly appreciated. So far I've managed to come up with:
/(?<!as )(?>([A-Z0-9_-]*)\.([A-Z0-9_-]*))(?![ ]+as[ ]+[A-Z0-9_\-.]+)/i

but that doesn't seem to work as it sees the expression alias.name as not
being preceeded by "as ".

Thanks!

Eric

Jul 19 '05 #1
1 3476
In article <11***************@www.vif.com>, Eric B.
<eb****@hotmail.com> wrote:
Hi,

I'm hoping someone can help me come up with a regular expression that I need
to match the following.

I'm looking to match all occurances of format <word>.<word> in a string that
is not followed by the words AS. This is coming from an SQL select
statement.
Select
payment_module.module_name as `alias.name`,
payment_module.module_description,
payment_module.is_enabled,
configuration.configuration_key,
configuration.configuration_value,
configuration.store_id as `alias.storeid`

Any help would be greatly appreciated. So far I've managed to come up with:
/(?<!as )(?>([A-Z0-9_-]*)\.([A-Z0-9_-]*))(?![ ]+as[ ]+[A-Z0-9_\-.]+)/i

but that doesn't seem to work as it sees the expression alias.name as not
being preceeded by "as ".


Unaliased table.column names are followed directly by a comma (at least
in all of your examples), so you can use:

/([\-\w]+)\.([\-\w]+)\s*,/ig

Note the following:

1. you need the 'g' modifier to catch all occurrences on a line.
2. the \w character class is equivalent to [a-zA-Z_0-9]
3. you need to escape '-' to use it as is in a character class (2
occurrences in your reqex do not).
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 19 '05 #2

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

Similar topics

12
by: hq4ever (at) 012 (dot) net (dot) il | last post by:
function testemail($email) { $validEmailExpr = "^(?)*@(?)*$"; return eregi($validEmailExpr, $email); } $email = "foo@bar.gov.mil"; testmail($email); //return TRUE
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
4
by: pekka niiranen | last post by:
Hi there, I have perl script that uses dynamically constructed regular in this way: ------perl code starts ---- $result ""; $key = AAA\?01; $key = quotemeta $key; $line = " ...
9
by: Dieter Vanderelst | last post by:
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our...
6
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address...
18
by: yawnmoth | last post by:
Say I have the following script: <? $string = 'test'; if (eregi("^+$",$string)) { echo 'matches!'; } else {
3
by: John Nagle | last post by:
Here's a large Perl regular expression, from a Perl address parser in CPAN: use re 'eval'; $Addr_Match{street} = qr/ (?: # special case for addresses like 100 South Street...
4
by: negzero7 | last post by:
Hi everyone, I am trying to teach myself Perl with the aid of some books I have boughten. I'm doing some exercises with regular expressions but am having some trouble, specifically with this...
3
by: William Gill | last post by:
I am not to sharp on my regular expressions because I haven't used them in quite a while. So I am relearning regex and the PHP regex functions at the same time. Which means when I screw up, I'm...
9
by: Rene | last post by:
I'm trying to basically remove chunks of html from a page but I must not be doing my regular expression correctly. What i'm trying with no avail. $site = preg_replace("/<!DOCTYPE(.|\s)*<div...
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:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.