Extract String Parts with Left(), Right() and Mid()

Use Left(), Right() and Mid() to extract characters from different parts of a VBScript string.

Right()

My_string=Right(string_var, number)

number is the number of characters to return from the right side.

Dim string_var, string_part
string_var="Welcome to plus2net.com"
string_part=Right(string_var, 3)
Response.Write string_part

Output

com

Left()

string_part=Left(string_var, 10)

Output

Welcome to

Mid()

Mid(string_var, starting_from, length)

Mid() uses a 1-based starting character position. The length argument is optional; if omitted, characters from the starting position to the end are returned.

string_var="Welcome to plus2net.com"
string_part=Mid(string_var, 12, 12)

Output

plus2net.com

Extract part of a URL string

string_var="https://www.google.com"
string_part=Mid(string_var, 9, 14)
Response.Write string_part

Output

www.google.com
The original URL example started at position 8, which includes the second slash. Because VBScript string positions are 1-based, www.google.com begins at position 9 in https://www.google.com.

ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer