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

  • SEARCH
  • Home
  • 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 8386699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:00:55+00:00 2026-06-09T18:00:55+00:00

I have been working on some legacy code in our application that detects certain

  • 0

I have been working on some legacy code in our application that detects certain keywords in the text of an SQL stored procedure by using Regex and I have found a bug that I can’t quite correct due to my limited knowledge of Regex.

Basically the regex that I currently have works in all but one case:

(?<=\n\s*)(?<!with.*[\s\S]*)as

It should return a match on this version of a stored procedure:

ALTER PROCEDURE [dbo].[p_obj_name_with_something] 
    @username [nvarchar](100) = null,
    @id [int] = null,
    @mode [int] = 0
AS
/*-------------------------------------------------------------------------

However it shouldn’t for this version, but it currently does return a match:

ALTER PROCEDURE [dbo].[p_obj_name_with_something] 
    @username [nvarchar](100) = null,
    @id [int] = null,
    @mode [int] = 0
WITH EXECUTE AS CALLER
AS
/*-------------------------------------------------------------------------

I want a match when the keyword WITH isn’t found before the AS keyword, but it will allow the word within the name or parameters of the stored procedure.

The way I think the detection would work is if the keyword WITH has whitespace (or a newline) either side of it, but I can’t quite figure out the regex syntax.

Any suggestions?

  • 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-06-09T18:00:57+00:00Added an answer on June 9, 2026 at 6:00 pm

    Even though it isn’t a real answer, I found the easier way to do this was to enforce some naming convention rules in our stored procedures and modify the 20 or so that violated the rules.

    Indeed, this is a case when Regex is not the solution!

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

Sidebar

Related Questions

I have been working on some legacy C++ code that uses variable length structures
I have some really complicated legacy code I've been working on that crashes when
I have been working on some code that prints a textbox that lists contact
I currently am working on a legacy application and have inherited some shady SQL
For the past year I've been working on some legacy code that was written
I have been working on some code to submit an uploaded image to PHP
I have one web application which I have been working for some time.I am
I have been working on a website that has some images that I need
I've been working on some solutions for some questions that have been recently posted
I have seen a couple of instances now where some legacy code I'm working

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.