regexp across some lines

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
ynixon
Posts: 3
Joined: Thu May 24, 2007 12:14 am

regexp across some lines

Post by ynixon » Thu May 24, 2007 12:47 am

I am trying to use regexp to identify ONLY the commands that hasn't the word "tablespace" within it. a command starts with "create table" and ends with ; (semicolon)
unsuccessfully I tried:
objRegEx.Pattern = "creates*table[S|s]*?;"
and also
objRegEx.Pattern = "creates*table[S|s]*?(?!tablespace)[S|s]*?;"

example file:
=========================
create table first tablespace ;
create table second( BBL_CUSTOMER_NAME VARCHAR2(32),a tablespace af);
create table third( BBL_CUSTOMER_NAME VARCHAR2(32),);
create table forth( BBL_CUSTOMER_NAME VARCHAR2(32) );
================================
the match should be:
================================
create table third( BBL_CUSTOMER_NAME VARCHAR2(32),);

create table forth( BBL_CUSTOMER_NAME VARCHAR2(32) );
====================================

HELP MEynixon2007-05-25 00:56:15

User avatar
ynixon
Posts: 3
Joined: Thu May 24, 2007 12:14 am

regexp across some lines

Post by ynixon » Thu May 24, 2007 12:47 am

I am trying to use regexp to identify ONLY the commands that hasn't the word "tablespace" within it. a command starts with "create table" and ends with ; (semicolon)
unsuccessfully I tried:
objRegEx.Pattern = "creates*table[S|s]*?;"
and also
objRegEx.Pattern = "creates*table[S|s]*?(?!tablespace)[S|s]*?;"

example file:
=========================
create table first tablespace ;
create table second( BBL_CUSTOMER_NAME VARCHAR2(32),a tablespace af);
create table third( BBL_CUSTOMER_NAME VARCHAR2(32),);
create table forth( BBL_CUSTOMER_NAME VARCHAR2(32) );
================================
the match should be:
================================
create table third( BBL_CUSTOMER_NAME VARCHAR2(32),);

create table forth( BBL_CUSTOMER_NAME VARCHAR2(32) );
====================================

HELP MEynixon2007-05-25 00:56:15

User avatar
ynixon
Posts: 3
Joined: Thu May 24, 2007 12:14 am

regexp across some lines

Post by ynixon » Thu May 24, 2007 3:50 am

your suggestion is so simple.... and I am shame that I didn't think about it.
actually the first pattern I used identifing the block

thanks very muchynixon2007-05-24 10:50:53

User avatar
jvierra
Posts: 12950
Joined: Tue May 22, 2007 9:57 am
Contact:

regexp across some lines

Post by jvierra » Thu May 24, 2007 3:27 pm

Someone says that maybe RegEx can't easily handle something. Well - look at teh quote below. RegEx is "grredy"? Never heard that before but then it can "gobble" things up. ( follow links for more goodies on regula expressions )




Regular expression conundrum

Monday, May 21, 2007, 3:02:06 AM | Mike Pope<mikes.weblog@gmail.com>
I'm trying to use regex to match URLs (who isn't?), and I have one of those close-but-not-quite situations. From the marvelous Expresso, I get this expression:(?<Protocol>w+)://(?<Domain>[w.]+/?)S*which works great. Except ... the last bit (S*) does a greedy match gobbling up non-whitespace characters. My problem is that I often have URLs followed by something like <br/>, which isn't considered whitespace, so yon greedy match plows right on by the HTML tag until it gets to some real whitespace, where it finally stops.Update: Actually, this works (doesn't work) just as well for my purposes: http://(S*).What I need is an expression that says something like "stop when you hit whitespace or the '<' character." My experimentation suggests that you can't OR a greedy expression like (S*), although I might just not be doing this exactly right.This is currently flummoxing me. Ideas?Update: Ok, maybe I got it:http://([^s|^<])*

From Mike Pope's WebLog
http://www.mikepope.com/blog/DisplayBlo ... 2007-05-24 22:31:26

Locked