StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Need help creating RegEx expression...Expand / Collapse
Author
Message
Posted 08/17/2006 1:37:34 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/09/2008 2:20:16 PM
Posts: 436, Visits: 944
These are my examples:

SELECT *
INTO #TEMP
FROM TABLE

SELECT * INTO #TEMP FROM TABLE

I would like some help creating a RegEx pattern to find the word INTO followed by a space then a pound sign (#) then a wildcard for the temp table name then another space.

Thanks
Post #2238
Posted 08/17/2006 1:49:32 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/02/2008 4:42:46 PM
Posts: 2,686, Visits: 1,890
System.Text.RegularExpressions.RegEx.IsMatch(myvalue, "into #(\w*?)( |$)", System.Text.RegularExpressions.RegexOptions.IgnoreCase Or System.Text.RegularExpressions.RegexOptions.Multiline)

The actual recular expression would be this:

into #(\w*?)( |$)

Make sure you use RegexOptions values so that the "into" will match "INTO" and so that the $ will match the end of a line.


www.bungie.net
Post #2240
Posted 08/17/2006 1:57:24 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/09/2008 2:20:16 PM
Posts: 436, Visits: 944
Thanks! Would you mind briefly explaining to me how you created that expression? I'm new to RegEx expressions and having a hard time understanding how they work.

The expression you created will find the INTO statement whether it is on a line by itsself or on one line with the rest of the SQL statement?

Post #2241
Posted 08/17/2006 2:00:02 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 7:08:30 PM
Posts: 4,811, Visits: 4,781
This is a very long a deep topic.  One thing I might suggest is purchasing a copy of RegExBuddy (http://www.regexbuddy.com/) which will allow you to create and test expressions within an editor.  You can then take those expressions and import them over to .NET.

There is really no such thing as a "brief" explanation when it comes to RegEx.

Post #2242
Posted 08/17/2006 2:02:33 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/02/2008 4:42:46 PM
Posts: 2,686, Visits: 1,890
I think it's only like $29 or something like that.

As for finding the INTO if it's on it's own line, no, you'll need to replace the first " " with a ( |$) or something like that.


www.bungie.net
Post #2244
Posted 08/17/2006 2:05:04 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/02/2008 4:42:46 PM
Posts: 2,686, Visits: 1,890
RegexBuddy, we use it all the time




www.bungie.net
Post #2245
Posted 08/17/2006 2:21:31 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/09/2008 2:20:16 PM
Posts: 436, Visits: 944
Thanks guys! This is awesome information... I've submitted the PO for the RegExBuddy.

The expression wont find the INTO #TEMP on its own line... it'll only find the one thats on the same line. What do I need to change?
Post #2248
Posted 08/17/2006 2:27:33 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 12/02/2008 4:42:46 PM
Posts: 2,686, Visits: 1,890
Try this:

\binto\b.*?#(\w*)\b

However, use RegexOptions.SingleLine instead of MultiLine.


www.bungie.net
Post #2249
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 4:11am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.125. 9 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.