Solved

how do i refine my subexpression regex matching?

Posted on 2007-11-15
35
501 Views
Last Modified: 2013-11-07
Consider the following .NET Regex query:

"SELECT[ ](.*\r\n.*FROM.*\r\n.*WHERE.*\r\n.*)"\r

As you can see i’m trying to match part of SQL syntax. The aim is to find specifically structured literal SQL queries in source code – ie, SQL queries comprised of concatenated strings. I am searching over multiple lines so i have the MultiLine option enabled and for the moment i am matching casing as most of the code uses uppercase SQL keywords.

My struggle arises from group #1 in the above query – it’s too inflexible at the moment. I may or may not have the FROM and WHERE keywords on the same line and they may or may not be separated by only one line, ie. I set of \r\n (windows files btw); yet i still need to match this ‘meaty’ part of the SQL command... and i need more filters.

I don’t know how to use Lookahead or Lookbehind assertions or even Backreferences. Nor do i know if i need to use these constructs (for the said reason). So without trying to learn something that already is screwing with my head i want to know if there is someone out there who can point me in the right direction for the use of Lookahead/Lookbehind/Backreferences in this situation, or if they are even necessary. I am trying to understand these constructs and maybe a couple of applicable examples will get me on my way.

I need to be able to rewrite this query for a number of scenarios:
-      Some where i have JOIN keywords present, some without JOIN
-      Some with WHERE keywords, some without WHERE
-      I would also like to be able to tell if there are multiple tables being sourced in the SQL query and even quantify that – specify a minimum of 2 tables sourced for example
-      I need to match, as i mentioned above, the situations where different clause parts of the SQL are spread over multiple lines so i’d like to put a {0,3} quantifier near my .*\r\n.* sections but i don’t know how to do this
I’m thinking that Lookahead/Lookbehind/Backreferences are part of my solution but i don’t know how. If you can provide ideas for even part of one of the above problems, i’d appreciate it.

thanx


[edit: trying to remove bad characters rendered by html]
0
Comment
Question by:cottsak
  • 16
  • 8
  • 8
  • +1
35 Comments
 
LVL 17

Expert Comment

by:NicksonKoh
ID: 20295599
Hi cottsak,

To overcome multiple lines I always remove them first with a regex like [\r\n\f]. Set Globals = True and remove those carriage returns with  re.Replace(str, "").

Cheers,
NicksonKoh
0
 
LVL 17

Expert Comment

by:NicksonKoh
ID: 20295655
cottsak,

You can also ignore multilines with re.Multiline = True and you can post some SQL examples what need to be captured for an easier understanding.

Cheers,
NicksonKoh
0
 
LVL 6

Author Comment

by:cottsak
ID: 20296283
NicksonKoh,

I’m trying to do all matching with the regex. I don’t want to have to introduce programmatic iterations for a specific regex expression (ie. The removing of carriage returns etc).
I don’t want to remove the MultiLine option as i need my regex to include the lines in the capture.
I’m not allowed to post the code i’m searching but it’s easy to imagine – concatenated strings resulting in one large SQL string to be executed.

Appreciate your help.

0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20296324
Instead of providing nonspecifc references to instances you need to match please provide actual text examples you need to match.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20306314
I am not sure I understand your question correctly.  Like Ddrudik I am interested in specific examples and maybe a clearer explanation.

However as I read this it seems the "dot matches newline" option is what you need.  Depending on the regex flavor or language you use this may not be an option or the method of specifying it can be different.  In C#.NET (and some other .NET languages) this is done with the SingleLine option.  For example ...

      if (Regex.IsMatch(subjectString, ".+", RegexOptions.Singleline)) {

The multiline option (which was mentioned above) usually refers to the start and end of line characters in the regex.

One other method, especially if the "dot matches newline" or Singleline option isn't available is to use something besides the dot character for 'any' character.  One that I like to use is ...

[\s\S]

Let me know if you have a question about those shorthand character classes or anything above.  I hope it helps.  If not please clarify the question and provide some specific examples.

bol
0
 
LVL 6

Author Comment

by:cottsak
ID: 20309787
the following is an example of the sort of thing i want to match:

"SELECT [thing] " + ;
"FROM aField " + ;
"WHERE (Some_ID = " + NTrim(nSomeID) + ") AND (Something_Code != 'W') " + ;
"ORDER BY [thing]"

Perhaps i can qualify with this:
a period "." that matches New Line "\n" (hopefully "\r\n" in the .NET case) might be helpful in replacing the ".*\r\n.*" sections of the query however what i'm really trying to do is
"match any character where within that multi-character-any-character match i must also match 'FROM'"
OR
"match any character where within that multi-character-any-character match i must also match 'WHERE'"
OR
"match any character where within that multi-character-any-character match i must also match 'INTO' and 'INNER JOIN'"

does this make more sense?
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20312668
With your sample of:


This pattern seems to match:
SELECT\s+(?<select>[^\s]+)\s+FROM\s+(?<from>[^\s]+)\s+WHERE\s+(?<where>.*?(?=\sORDER\sBY|$))(?<orderby>.*?$)

Without an example of INTO/INNER JOIN I am not clear on how you need the pattern modified to allow for those conditions.  Also, if you don't need capture groups the pattern can be greatly simplified. If you have more text in the string you are matching against other than this SELECT statement the pattern will also need to be modified for that, if that's the case please provide actual text sample you want to match against--theoretical examples will get you theoretical answers.
0
 
LVL 6

Author Comment

by:cottsak
ID: 20317812
ddrudik,

i ran your expression on my data and it did not match. your expression does not match over multiple lines.

btw: no, my expression does not need to return groups.. named or otherwise. it may however, require subexpression assertions or lookahead/lookbehind

assertions like i stated in the initial question.

here are some samples of data i want to match:

a)


"SELECT r.dlkjb_ID, r.[Name], r.Status_Code, p.Lawnrover_Code, p.portal_No " + ;
                        "FROM tensigh r INNER JOIN redmik p ON r.dlkjb_ID = p.dlkjb_ID " + ;
                        "WHERE (r.Status_Code = 'A') AND (p.portal_No IS NOT NULL) AND (r.Stamp_Action_Code != 'D') " + ;
                        "ORDER BY p.Lawnrover_Code, Name"


in the above example note (1) that it needs to match over multiple lines. i'm using "\r to define the end of the SQL statement that i wish to match. currently i use the exact case match of "SELECT[ ] to denote the start of the matched data.

b)


"SELECT * FROM KONGA " + ;
                          " WHERE (dbo.udf_Strip_Punctuation(" + cSearchBy + ") LIKE " + ;
                          AsSQLString(StripPunc(cSearch)) + ")"


the above example shows how the new line may or may not appear between SQL keywords - SELECT and FROM on same line

c)


"SELECT r.karma_ID, r.korma_Code, r.Status_Code, r.Fish_Type, r.[Name], " + ;
                              "IsNull(p.Motorbike_Code, ' ') AS Motorbike_Code " + ;
                        "FROM FTP_Magnet r LEFT OUTER JOIN Naght p ON r.karma_ID = p.karma_ID " + ;
                        "WHERE (r.Stamp_Action_Code != 'D') AND (r.korma_Code IN ('P', 'U')) " + ;
                        "ORDER BY [Name]"


this example (above) shows how between keywords there may be more than one line

d)


"SELECT [Type], [Sequence], [DateTime] " + ;
                        "FROM KO_Shift " + ;
                        "WHERE (Tenor_ID = " + NTrim(nTenorID) + ") AND (Stamp_Action_Code != 'D') "
            nLen := ALen(aFilter)
            IF nLen != 0
                  cSQL += "AND ("
                  FOR i := 1 UPTO nLen
                        IF i != 1
                              cSQL += " OR "
                        ENDIF
                        cSQL += "([Type] LIKE " + AsSQLString(aFilter[i]) + ")"
                  NEXT
                  cSQL += ") "
            ENDIF
            cSQL += "ORDER BY [DateTime], [Type], [Sequence]"


this last example above shows how i want to match an SQL statement over other code logic (other than simply string concat code). note the "\r still matches the and and "SELECT[ ] still matches the start.










to refine further my question:

think of the expression matching 3 logical sections:
- the start of the SQL statement
- the middle of the statement
- and the end of the statement

i need a regular expression that matches the whole statement where it allows the start to be SELECT or maybe INSERT INTO or UPDATE
perhaps the start of the regex would look like this:
"((SELECT)|(UPDATE)|(INSERT INTO))
btw, i'm not sure if all the parenthesis are necessary
the end of the statement for now can be matched by "\r but at a later stage it may need to be more intelligent
the middle of the statement needs the juicy matching
i want to be able to match any valid literal SQL syntax while matching the syntax of the surrounding code it's tangled within. additionaly i can use exact case matching to specify that i must have JOIN and WHERE keywords in the middle section, such that example (c) matches but none of the others. or maybe i want to change the start section to match SQL statements that start with UPDATE but contain (middle section) nested SELECT statement(s). i dont know how to express this in regex. please help
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20320102
You should really include actual samples of UPDATE and INSERT INTO text to match since they may not contain ORDER BY etc.
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20320246
I don't see an easy way to recognize the d) sample, but here's one for a)-c):
"SELECT[\S\s]*?"\r(?=\n)
0
 
LVL 6

Author Comment

by:cottsak
ID: 20324532
ddrudik,

can u please break down, and explain your last suggestion?
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20324911
"SELECT = match literal text "SELECT
[\S\s] =  any character in \S\s character groups (basically any character)
* =  0 or more times
? = match until following character is located
"\r = literal character " followed by \r
(?=\n) = match \n but exclude from capture

In code you may need to format it as:
"""SELECT[\S\s]*?""\r(?=\n)"
0
 
LVL 6

Author Comment

by:cottsak
ID: 20332252
can someone please tell me if  Lookahead/Lookbehind/Backreferences are or are not required/necessary in this solution and give reasons why?
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20336766
A good regex tutorial site:
http://www.regular-expressions.info/

Given my explanation of my pattern above if you still have questions and/or problems please be specific on what issues you are experiencing.  

Including or excluding lookaheads/lookbehinds/backreferences is entirely based on your needs given your source text and what you want to match etc.
0
 
LVL 6

Author Comment

by:cottsak
ID: 20336935
i've given so much examples. i dont know how to be more explicit.

i'll try again:
i need to match SQL statements embedded in source code.
i'm looking for relationships, so i need 2 or more tables.
a relationship might be defined in a WHERE clause, a JOIN of some sort or any combination of these, even in nested select statements.
any of the above may come from a SELECT statement, UPDATE or even stuff like INSERT

i dont know how to make this any clearer.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20337664
Is this just about handling newlines?  If so, then don't use the dot character unless you use the Singleline option in the .NET regex.  The other options to the dot character are to use the [\s\S] that I suggested above or, if you know there will be specific characters that "separate" a section, use them.  An example of the latter method is ...

   If you had "all I want is 'in here' but not out"

then use ...

   '([^']+)' // grab chars that aren't a single quote

Those are the methods to get around the dot not handling a newline.

Your recent summary helped a bit.  Thanks!  However you are still being general but asking for a VERY specific expression.  It isn't clear what you mean by the relationships you are looking for.  Do you want all of the parts of an expression or just table names?  If you need tables then why worry about WHERE and some of the other sql query terms?  Very few will preceed a table name and you can look for just those.

I did make an expression that will grab the string blocks for the SQL samples you posted above.  It uses lookbehind and lookahead (both positive) but that part isn't really important, just convenient and .NET supports it.  However there is no way for this or probably any expression to get the parts of the query that use variables, etc.  Only the string part.

A real explanation of lookaheads will need its own question, if not separate questions for each one.  If you really want to learn about them then read Mastering Regular Expressions by Jeff Friedl.  Ddrudik's tutorial is good too but a little harder to understand for most since it is condensed.  The concept isn't easy to really explain in comment or even a whole question.

Let me know how this helps or if you have a question.  If you don't have the option to provide more detailed info to us then you might need to look at a different method to solve this (i.e. hire someone).  Details are very important to making an expression.  Hopefully this works though or you can provide answers to the questions I just asked.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20337667
Oh, the expression for the samples above to get the sql "strings" is ...

(?<=")(?:[^"]*\b(?:SELECT|DELETE|UPDATE|INSERT INTO|FROM|WHERE|BETWEEN|IN|JOIN|GROUP BY|ORDER BY|AND|LIKE|OR)\b[^"]+)(?=")

bol
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Author Comment

by:cottsak
ID: 20371317
bol,

please explain what ur grouping constructs do for ur above expression in the context of my problem.

also, i tested ur expression and it works ok i guess. this works better:
"(INSERT|SELECT|UPDATE) [\s\S]*?("|\))\r
... (ignoring the rest of the SQL keywords) i suspect it's my expression targets the beginning and the end of the desired text better.. but i think ur grouping ideas may be the ticket for the 'middle section'. please explain what it does so that we might be able to adapt it.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20371512
The "groupings" are used for 2 reasons.  Neither actually captures anything.

(?<=") ... (?=") - These groups are called lookarounds.  The first is called a lookbehind and the second lookahead.  Both are "positive" types of lookarounds.  A complete explanation can be complicated but the basic idea is it makes sure the expression only matches characters in between double quotes.  The sql you are looking for is in strings and so there is we make sure we only get a match in quotes.  The advantage of the lookaround is the double quote will not actually be part of the match.

(?:[^"]*\b(?:SELECT|DELETE|UPDATE|INSERT INTO|FROM|WHERE|BETWEEN|IN|JOIN|GROUP BY|ORDER BY|AND|LIKE|OR)\b[^"]+) - In this case both uses of parentheses is just to group the expression.  The (?: part will make it so the engine does not capture (or keep/remember) that part of the expression.  It just makes the expression a little more efficient.

Neither one of these are really keys to the expression though.  The lookarounds could just be replaced by a leading and trailing double quote.  The non-capturing group could just be made into a normal group.

I hope that helps.  If not then please explain again and include some specific results.  I am afraid I don't really understand what you mean above.  Let me know if you have a question about what I said or what I need.

bol
0
 
LVL 6

Author Comment

by:cottsak
ID: 20371588
bol,

good explanation.. but like u said, it dont really target my core problem.

consider this: if i added functionality to my app to allow nested regex searching - whereby i could search previously matched text with a new expression. i could say, select all my SQL sxpressions with this:
"(INSERT|SELECT|UPDATE) [\s\S]*?("|\))\r
...which works quite well. then i could search those results for particular SQL statement types and/or meet my 2+ table requirements (as mentioned above) by searching for certain groups of keywords like WHERE and JOIN. this would filter my say 700 matches down to maybe less than 100 matches and i could manually search the rest by hand [and finally finish this darn project]. BUT, if i can create a regular expression to do this on one go, it would be better. savvy?
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20400520
At least I am glad my suggestion of [\s\S] is working well for you. :)

I understand in a basic way what you are after.  However if you want the magic expression then you need to provide a very accurate sample of what will be searched and let me know exactly what you want.  I worked with the sample you provided and gave an expression that would get the SQL sections from it.  I can post the result I got using that expression if it will help.  If you did not get the results you wanted then exactly what do you expect to get as the result from the expression.  I have tried to ask for this before but I don't see that you have let us know.

You might not be able to make one expression for this or, even if you could, it would be very inefficient.  There are times where you have to use steps and script to get what you need; one expression or line of code won't do it.

Let me know if you have a question about anything I have said.  I won't be able to do anything else for an expression though unless some new info and details are provided.  I am glad my general comments have helped to give you [\s\S].

bol
0
 
LVL 17

Expert Comment

by:NicksonKoh
ID: 20400565
Just to add on, creating overly complex regular expression can be very bad. Regular expression is by itself very cryptic and very few people are even proficient with it. Maintenance can be nightmare even for yourself when trying to decipher a complex expression!
0
 
LVL 6

Author Comment

by:cottsak
ID: 20400625
bol,
isnt the comment with ID:20317812 enuf examples?
i'd really like to just copy-paste KB worth of text i'm searching but it's protected material and obfuscating the examples above was hard enuf.

NicksonKoh,
thanx for the tip. i'm not looking for an overly complex regex, just a concise and optimised one. i understand ur point tho, i'm fighting an issue presently known as Catastrophic Backtracking and the regex is not complex or very long.. it's just trying to understand the underlying engine that messes my head up.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20400911
"I worked with the sample you provided and gave an expression that would get the SQL sections from it. ...  If you did not get the results you wanted then exactly what do you expect to get as the result from the expression."

What EXACTLY do you want for results from that sample?  This still isn't clear.

bol

[results using my expression attached in code snippet]
SELECT r.dlkjb_ID, r.[Name], r.Status_Code, p.Lawnrover_Code, p.portal_No 

FROM tensigh r INNER JOIN redmik p ON r.dlkjb_ID = p.dlkjb_ID 

WHERE (r.Status_Code = 'A') AND (p.portal_No IS NOT NULL) AND (r.Stamp_Action_Code != 'D') 

ORDER BY p.Lawnrover_Code, Name

SELECT * FROM KONGA 

 WHERE (dbo.udf_Strip_Punctuation(

) LIKE 

SELECT r.karma_ID, r.korma_Code, r.Status_Code, r.Fish_Type, r.[Name], 

FROM FTP_Magnet r LEFT OUTER JOIN Naght p ON r.karma_ID = p.karma_ID 

WHERE (r.Stamp_Action_Code != 'D') AND (r.korma_Code IN ('P', 'U')) 

ORDER BY [Name]

SELECT [Type], [Sequence], [DateTime] 

FROM KO_Shift 

WHERE (Tenor_ID = 

) AND (Stamp_Action_Code != 'D') 

AND (

 OR 

([Type] LIKE 

ORDER BY [DateTime], [Type], [Sequence]

Open in new window

0
 
LVL 6

Author Comment

by:cottsak
ID: 20401105
bol,
this comment spans the next few comments:


here is the source text (see code snip):
a)
 
 

"SELECT r.dlkjb_ID, r.[Name], r.Status_Code, p.Lawnrover_Code, p.portal_No " + ;

                        "FROM tensigh r INNER JOIN redmik p ON r.dlkjb_ID = p.dlkjb_ID " + ;

                        "WHERE (r.Status_Code = 'A') AND (p.portal_No IS NOT NULL) AND (r.Stamp_Action_Code != 'D') " + ;

                        "ORDER BY p.Lawnrover_Code, Name"
 
 

in the above example note (1) that it needs to match over multiple lines. i'm using "\r to define the end of the SQL statement that i wish to match. currently i use the exact case match of "SELECT[ ] to denote the start of the matched data.
 

b)
 
 

"SELECT * FROM KONGA " + ;

                          " WHERE (dbo.udf_Strip_Punctuation(" + cSearchBy + ") LIKE " + ;

                          AsSQLString(StripPunc(cSearch)) + ")"
 
 

the above example shows how the new line may or may not appear between SQL keywords - SELECT and FROM on same line
 

c)
 
 

"SELECT r.karma_ID, r.korma_Code, r.Status_Code, r.Fish_Type, r.[Name], " + ;

                              "IsNull(p.Motorbike_Code, ' ') AS Motorbike_Code " + ;

                        "FROM FTP_Magnet r LEFT OUTER JOIN Naght p ON r.karma_ID = p.karma_ID " + ;

                        "WHERE (r.Stamp_Action_Code != 'D') AND (r.korma_Code IN ('P', 'U')) " + ;

                        "ORDER BY [Name]"
 
 

this example (above) shows how between keywords there may be more than one line
 

d)
 
 

"SELECT [Type], [Sequence], [DateTime] " + ;

                        "FROM KO_Shift " + ;

                        "WHERE (Tenor_ID = " + NTrim(nTenorID) + ") AND (Stamp_Action_Code != 'D') "

            nLen := ALen(aFilter)

            IF nLen != 0

                  cSQL += "AND ("

                  FOR i := 1 UPTO nLen

                        IF i != 1

                              cSQL += " OR "

                        ENDIF

                        cSQL += "([Type] LIKE " + AsSQLString(aFilter[i]) + ")"

                  NEXT

                  cSQL += ") "

            ENDIF

            cSQL += "ORDER BY [DateTime], [Type], [Sequence]"

Open in new window

0
 
LVL 6

Author Comment

by:cottsak
ID: 20401112
... using this regex:
"(INSERT|SELECT|UPDATE) [\s\S]*?("|\))\r
i get the following 4 results:

hit#1
ee_sample.txt p=8, l=357
"SELECT r.dlkjb_ID, r.[Name], r.Status_Code, p.Lawnrover_Code, p.portal_No " + ;
                        "FROM tensigh r INNER JOIN redmik p ON r.dlkjb_ID = p.dlkjb_ID " + ;
                        "WHERE (r.Status_Code = 'A') AND (p.portal_No IS NOT NULL) AND (r.Stamp_Action_Code != 'D') " + ;
                        "ORDER BY p.Lawnrover_Code, Name"

hit#2
ee_sample.txt p=622, l=184
"SELECT * FROM KONGA " + ;
                          " WHERE (dbo.udf_Strip_Punctuation(" + cSearchBy + ") LIKE " + ;
                          AsSQLString(StripPunc(cSearch)) + ")"

hit#3
ee_sample.txt p=937, l=408
"SELECT r.karma_ID, r.korma_Code, r.Status_Code, r.Fish_Type, r.[Name], " + ;
                              "IsNull(p.Motorbike_Code, ' ') AS Motorbike_Code " + ;
                        "FROM FTP_Magnet r LEFT OUTER JOIN Naght p ON r.karma_ID = p.karma_ID " + ;
                        "WHERE (r.Stamp_Action_Code != 'D') AND (r.korma_Code IN ('P', 'U')) " + ;
                        "ORDER BY [Name]"

hit#4
ee_sample.txt p=1441, l=193
"SELECT [Type], [Sequence], [DateTime] " + ;
                        "FROM KO_Shift " + ;
                        "WHERE (Tenor_ID = " + NTrim(nTenorID) + ") AND (Stamp_Action_Code != 'D') "



.. these results only using the .NET regex with MultiLine enabled
0
 
LVL 6

Author Comment

by:cottsak
ID: 20401124
what i want to do is modify this:
"(INSERT|SELECT|UPDATE) [\s\S]*?("|\))\r
into something that i can run against the above sample (comment 20401105) that only returns the results that have the keyword "JOIN" in them. ie. hit#1 and hit#3.
make sense?
0
 
LVL 6

Author Comment

by:cottsak
ID: 20504153
please, can someone help me further?
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 250 total points
ID: 20534807
You will need to do this with code, performing a check of each match for "JOIN", do you still need help?
0
 
LVL 6

Author Comment

by:cottsak
ID: 20558910
thanx ddrudik. i am however looking for a solution from the regex itself.. without code.
0
 
LVL 54

Assisted Solution

by:b0lsc0tt
b0lsc0tt earned 250 total points
ID: 20559111
I have looked over the info you posted.  By the way, thanks, that did clear up some stuff.

I don't see that you can use one expression to do what you want.  Also, as I get close the expressions become very complex and would be less efficient than using a simpler expression with script or two expressions.  I mentioned this is can be the case in a previous comment (http:#20400520) and the specifics you posted just confirm this.  Let me know if you have a question about what I have said.  The other 2 experts that have commented here are very skilled, even with expressions, and could confirm this or might see something I am missing.  I would still say that any possible option would require a lot more work for your page than just a simpler expression and script.

bol
0
 
LVL 6

Author Comment

by:cottsak
ID: 20559453
b0lsc0tt,

ok. thank you for all your help. i too have run into issues with complex expressions in this quest. more specifically the .NET regex "nested quantifiers" O(n^x) problem.. this came about when i nested too many sub-expressions and the regex calls would appear to never return. in fact they were working but with huge backtracking which i have since learned is a big "no no". so alas, code IQ is necessary and my dream for the perfect regex is dashed :-(
on the bright side, i have learned much. my project design has turned to a multi-regex concept where different regex's may be evaluated on the same input in succession.. like nested filters.. this seems to get the desired result.

special thanx to b0lsc0tt and ddrudik. i'll leave you folks alone now.
0
 
LVL 6

Author Closing Comment

by:cottsak
ID: 31409482
much thanx
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 20559783
Thanks for the question and the points.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 20561135
Your welcome!  Thanks for the fun question, the grade and the points.  I really enjoyed trying to find that perfect regex for you and glad I could help. :)

bol
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now