Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
help with cutting the string
Logged in as: Guest
arrSession:exec spGetSession 2,2,54838
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> help with cutting the string
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
help with cutting the string -
1/2/2008 9:23:32 PM
tomas
Posts: 11
Score: 0
Joined: 1/2/2008
Status:
offline
Hi,
I'm having little trouble cutting the string, let's say I've got
Dim Foo Fool = "barbarbar123"
I need to cut foo and end up with only last 4 of its chars so NewFoo = "r123"
I've found simple regex script which I believe can be used to do that, but I just don't know how...
Option Explicit Dim myFakeEmail myFakeEmail = "CZC13TLblabla" WScript.Echo(FindMessageID(myFakeEmail)) Function FindMessageID(messageBody) Dim MyRegEx Set MyRegEx = New RegExp MyRegEx.IgnoreCase = True MyRegEx.Global = True MyRegEx.Pattern = "CZC13TL" Dim testMatch: testMatch = MyRegEx.Test(messageBody) If testMatch = True Then Dim myMatches: Set myMatches = MyRegEx.Execute(messageBody) Dim firstMatch: Set firstMatch = myMatches(0) FindMessageID = firstMatch.Value Else FindMessageID = "" End If Set firstMatch = Nothing Set myMatches = Nothing Set MyRegEx = Nothing End Function
Post #: 1
RE: help with cutting the string -
1/2/2008 10:01:01 PM
DiGiTAL.SkReAM
Posts: 1183
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status:
offline
If all you want is to take the last 4 on the right of the string,
sFoo = "barbarbar123" sNewFoo = Right(sFoo,4) wscript.echo sNewFoo
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers)
"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury
(in reply to
tomas
)
Post #: 2
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> help with cutting the string
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI