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 3235024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:27:33+00:00 2026-05-17T17:27:33+00:00

I have a large ASP.NET project where I want to do a mass search

  • 0

I have a large ASP.NET project where I want to do a mass search and replace (about 3500 instances)

I want to change

If strErrorMessage.Length > 0

If strSomeString.Length > 0

If strWhatever.Length > 0

and any other similar call to the Length method from a string to the following

If Len(strErrorMessage) > 0

If Len(strSomeString) > 0

If Len(strWhatever) > 0

Anyway to reliably do this in one shot?

I can do a search and replace for something like

If *.Length > 0 --> If Len(*) > 0 

This just won’t work though as it won’t understand how to rearrange it properly. Currently have VS2010 and N++ at my disposal.

Any ideas?

  • 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-17T17:27:34+00:00Added an answer on May 17, 2026 at 5:27 pm

    Using the Visual Studio Find/Replace (with the regex options enabled) you can use this:

    Find what: If {:a+}\.Length \> 0

    Replace with: If Len(\1) \> 0

    Pattern explanation:

    • :a+ = the :a matches an alphanumeric char, and the + matches at least one occurrence
    • {} in {:a+} = Visual Studio regex’s way of “tagging” (i.e., capturing) an expression
    • \> = the > must be escaped with a backslash since it’s a metacharacter in this regex flavor.
    • \1 = refers to the text matched in the tagged expression. The number 1 refers to the first (and only, in this case) tagged expression.

    You can read more about the MSDN regex reference for Find/Replace here.

    As I had mentioned in my comment, I think using Len() is a step backwards and ties your code down to the Microsoft.VisualBasic namespace. @drventure brought up a good point though, since calling .Length on a null value would throw an exception. Instead of checking the length you could use String.IsNullOrEmpty. In .NET 4.0 you can also use String.IsNullOrWhiteSpace.

    Instead of If strErrorMessage.Length > 0 you can use:

    If Not String.IsNullOrEmpty(strErrorMessage) Then
    ' or '
    If Not String.IsNullOrWhiteSpace(strErrorMessage) Then
    

    If you’re interested in using this you can keep the original “Find what” pattern and change the “Replace with” pattern to this: If Not String.IsNullOrEmpty(\1)

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

Sidebar

Related Questions

I have ASP.NET project and I want to know what is better to use.
We have a large ASP.NET project which has 100s of BLL classes. In our
I have to develop a fairly large ASP.NET MVC project very quickly and I
I have a very large ASP.NET project that i need to make good with
I am in the process of building a large asp.net Mvc project and have
So, my issue is that I have a fairly large ASP.NET 3.5 project that
I'm working on a large, complex ASP.NET project. I have a dynamically loaded web
Background: I have a project that is not at all large scale (2 ASP.NET
I have a ASP.NET MVC project with a large list of input textboxes which
I have to add a large amount of stereotyped pages to my ASP.Net Web-project.

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.