Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove short words from string 1

Status
Not open for further replies.

madanthrax

IS-IT--Management
Sep 15, 2001
123
AT
Hi,

Is there an elegant way of removing all words from a text string that are less than 4 characters in length please? This is search related.

[sub]"Nothing is impossible until proven otherwise"[/sub]​
 
Elegant?! Don't know what it means.
[tt]
set rx=new regexp
with rx
.global=true
.multiline=false
.pattern="(\s*\b\w{1,4}\b\s*)+"
'or effectively accepting only collapsing white space as well
'.pattern="(\s*\b\w{0,4}\b\s*)+"
end with
[green]'s be the string given
't be the processed string[/green]
t=rx.replace(s," ")
[/tt]
 
Excellent, works like a charm. Many thanks.

[sub]"Nothing is impossible until proven otherwise"[/sub]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top