Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Help with a Perl Regular Expression

Reply
Thread Tools

Help with a Perl Regular Expression

 
 
Eric B.
Guest
Posts: n/a
 
      12-17-2004
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



 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      12-17-2004
In article <>, Eric B.
<> 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 =-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
perl regular expression help uttamhoode@gmail.com Perl Misc 2 08-07-2006 08:25 AM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Help needed: cryptic perl regular expression in python syntax pekka niiranen Python 5 10-20-2004 12:39 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57