RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Return n words before and after a search term
Expression
(\s*\S*){2}(ipsum)(\S*\s*){2}
Description
pass in to your search term, a number and an expression to match. Replace the 2 and ipsum with those. Use the "matches" array to return all match strings. Is tolerant of word matches at start and end of string
Matches
(\s*\S*){<2>}(TEXT)(\S*\s*){2} matches "some TEXT to ... word TEXT singled … word TEXT." in "Here is some TEXT to match. Let's see the word TEXT singled out, sans the words between the word TEXT."
Non-Matches
n/a
Author Rating: Not yet rated. Tim vL
Source VBScript
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials