Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:23:37+00:00 2026-05-31T04:23:37+00:00

I quite often use the regular expression search and replace in SQL Server Management

  • 0

I quite often use the regular expression search and replace in SQL Server Management Studio 10.5 editor to clean up auto generated sql before use. The same behaviour described below occurs in Visual Studio 2010 editor as well.

I have the following sql insert statement that I’d like to clean up:

INSERT INTO [lttadev].[dbo].[GameInst]
           ([GameInstId]
           ,[GameSetId]
           ,[UserInfoId]
           ,[GameLevelId]
           ,[CreatedOn]
           ,[CreatedBy]
           ,[ModifiedOn]
           ,[ModifiedBy])
     VALUES
           (<GameInstId, uniqueidentifier,>
           ,<GameSetId, uniqueidentifier,>
           ,<UserInfoId, uniqueidentifier,>
           ,<GameLevelId, uniqueidentifier,>
           ,<CreatedOn, datetime,>
           ,<CreatedBy, uniqueidentifier,>
           ,<ModifiedOn, datetime,>
           ,<ModifiedBy, uniqueidentifier,>)

To alter the values clause I have the two following regular expressions:

,[^,]*,\>
\<

Both are replaced by an empty string to delete the unwanted text. The first one strips out the comma, type, second comma and final angle bracket. The second one strips out the initial angle bracket. Both work as expected.

However if I join the regexes up into a single expression to speed the text processing, they select different text:

(,[^,]*,\>|\<)

The first expression selects the expected text. However the second expression gets the first angle bracket as well as the preceding comma. Is this a defect in the regular expression engine or am I not understanding something here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:23:39+00:00Added an answer on May 31, 2026 at 4:23 am

    Try wrapping the first alternative in parentheses:

    (,[^,]*,\>)|\<
    

    The documentation doesn’t indicate what precedence | has, and it gives only this example:

    (sponge|mud) bath
    

    but elsewhere on that page are various examples where | is used with parentheses that would have been unnecessary (though harmless) in another regex engine:

    (("[^"]*")|('[^']*'))
    (- [a-z][1-3])|(- [0-9][a-z])
    (([0-9]+.[0-9]*)|([0-9]*.[0-9]+)|([0-9]+))
    

    so I’m guessing that | might have a fairly high precedence — lower than the trivial within-string concatenation of sponge or mud, but higher than more complex concatenations like in "[^"]*". (Of course, that last expression was written by someone who didn’t notice that . has a special meaning, so it may warrant a grain of salt.)

    Since I don’t have Visual Studio, I can’t test this out further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I quite often use Drupal's Views Module to build SQL that I paste into
I use Solr's proximity search quite often to search for words within a specified
We make use of views and panels quite often in Drupal and a lot
Dear experts, I am quite new to javascript and I often see coders use
I use the switch feature of Subversion quite often, but sometimes I forget where
I use vi quite often to edit files. Usually I need the file to
I use a binary library that crashes quite often. When it does, some times
I use the error log view in Eclipse quite often to track behaviour during
I'm using Visual Studio 2003 working on an ASP.NET application. Quite often, just in
By default the webjump hotlist has the following which I use quite often: M-x

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.