In SSMS if you just press Ctrl-F in the midst of typing SQL you will get a dialog box for the finding and if you expand the "Find options" you will see an option for using regular expressions. It's in a dropdown wherein you may either select regular expressions or wildcards to augment your searching. As T-SQL is not case sensitive neither is the regular expression searching which surprised me. What if you want to find against copy being inserted into a table cell enclosed in quotes where casing means something more. I suppose that is a fringe case. The rightward pointing arrow by the "Find what:" field will give you a helpful cheat sheet of RegEx pattern parts to use. A period represents any character so if you search against just . you will progress through every character in your SQL. A carat signifies the beginning of a line and a dollar sign the end of a line so searching for ^. will progressively find the beginning of every line (first character) which holds more than nothing while searching for .$ will progressively find the ends. You have to escape special characters if you actually want to search for the special characters as characters so \. will allow you to search for a period. * will match against zero or more characters and + will match against one or more characters. These modifiers apply to the pattern part immediately to their left so SE+ will find an S followed by one or more Es and the Es too while SE* is also just gonna find all of the Ss. I could go on. This is all pretty much what you'd expect from regular expressions, right?
No comments:
Post a Comment