0

I am using a regex within Visual Studio 2005 to turn my SQL statement into a readable string.

I am using the find expression {.*} and the replace expression & "\1 " _.

This should produce results something like: input:

select *
from x

expected

& "select * " _
& "from x " _

The reality is I am getting:

& "select * " _& " "_
& "from x " _& " "_

Have I got my expression wrong?

1 Answer 1

1

For your find pattern, use a + instead of a * to ensure at least one character is matched. I think something extra is being picked up with the * approach, perhaps a boundary or line-break despite the documentation.

Try this pattern instead: {.+}

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. I wonder if the * is treating the line break as a separate match, though this would make the new insert over 2 lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.