| | | 
StrataFrame 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 |
| | | | 
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 |
| | | | 
StrataFrame 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? |
| | | | 
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. |
| | | | 
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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 12/02/2008 4:42:46 PM Posts: 2,686, Visits: 1,890 |
| | | | | 
StrataFrame 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? |
| | | | 
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 |
| |
|
|