0

I have a situation where using VBScript I need to check for the presence of multiple spaces. I want to check for the presence of 2 or more consecutive spaces, so \s+ doesnt work for my needs.

Does anyone know how I can accomplish this using VBScript regular expressions.

1
  • 1
    \s+ doesn't work because it matches one or more spaces. What about just using \s\s+? Commented Oct 28, 2010 at 22:44

2 Answers 2

4

Use brackets to specify how many repetitions to match. This matches two or more whitespace characters:

\s{2,}

If you want to match only space characters, just use a space instead of \s, or the character code:

\x20{2,}
Sign up to request clarification or add additional context in comments.

1 Comment

+1 because we got the same answer at the same time, but I got the check.
2

This ought to do the trick:

\s{2,}

2 Comments

Thanks for your answers.This seems to also replace new line characters.
try [ ]{2,} then. You don't really need the brackets around the space, but it's hard to show the space in a comment here. Or do it as Guffa shows, using \x20 (representing the ASCII value of the space character. Either way, show your appreciation by upvoting us and/or giving someone a checkmark if our answers helped you.

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.