Advertisement
2002C String Manipulation #10096

_Code Snippet for VB's Split() Function

This is a one line code snippet to extract any section of a string using the Split() function. You can actually return the indexed section right in the same line as the Split() without having to assign the Split() to an array.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Place this line in your immediate window and run it. It will return "Test5".
Print Split("Test0 Test1 Test2 Test3 Test4 Test5 Test6", " ")(5)

Function LinkURLs(ByRef asContent)
	Dim loRegExp	' Regular Expression Object (Requires vbScript 5.0 and above)
	
	' If no content was received, exit the function
	If asContent = "" Then Exit Function
	
	' Create Regular Expression object
	Set loRegExp = New RegExp
	
	' Keep finding links after the first one.				
	loRegExp.Global = True
	
	' Ignore upper/lower case
	loRegExp.IgnoreCase = True
	' Look for URLs
	loRegExp.Pattern = "((ht|f)tps?://\S+[/]?[^\.])([\.]?.*)"
	' Link URLs
	LinkURLs = loRegExp.Replace(asContent, "<A href=""$1"">$1</A>$3")
	' Look for email addresses
	loRegExp.Pattern = "(\S+@\S+.\.\S\S\S?)"
	' Link email addresses
	LinkURLs = loRegExp.Replace(LinkURLs, "<A href=""mailto:$1"">$1</A>")
	' Release regular expression object
	Set oRegExp = Nothing
	
End Function
Commenti originali (3)
Recuperato da Wayback Machine