String manipulation with vbscript 
Author Message
 String manipulation with vbscript

Hi, all..
I'm looking for a VBScript function or code that does the following:

source: xx_yy_zz
dest    : yy_zz

What it is that I want to remove the first characters until it meets the
first "_" and remove the underscore as well.

Thank you in advance for your help



Mon, 21 Jun 2004 20:26:46 GMT  
 String manipulation with vbscript
Hi there,

You can use the "Instr" function which will return the position of the
underscore character and then using the "right" function you can remove
everything before the character and the character itself.

ie

dim source
source = "xx_yy_zz"
source = trim(source)
msgbox right(source, len(source) - instr(source, "_"))

It works for me anyway.  Hope it helps you.



Quote:
> Hi, all..
> I'm looking for a VBScript function or code that does the following:

> source: xx_yy_zz
> dest    : yy_zz

> What it is that I want to remove the first characters until it meets the
> first "_" and remove the underscore as well.

> Thank you in advance for your help



Mon, 21 Jun 2004 21:56:29 GMT  
 String manipulation with vbscript
dim l, p, dest, source
source = "xx_yy_zz"
l = Len(source)
p = InStr(source, "_")
if (p > 0) then  dest = Right(source, l - p)



Quote:
> Hi, all..
> I'm looking for a VBScript function or code that does the following:

> source: xx_yy_zz
> dest    : yy_zz

> What it is that I want to remove the first characters until it meets the
> first "_" and remove the underscore as well.

> Thank you in advance for your help



Mon, 21 Jun 2004 21:59:39 GMT  
 String manipulation with vbscript
(Requires VBScript 5.5+ for non-greedy ? quantifier)...

str = "ab_cd_ef"
set re = new regexp
re.pattern = ".*?_"
str2 = re.replace(str,"")
msgbox str2

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> Hi, all..
> I'm looking for a VBScript function or code that does the following:

> source: xx_yy_zz
> dest    : yy_zz

> What it is that I want to remove the first characters until it meets the
> first "_" and remove the underscore as well.

> Thank you in advance for your help



Mon, 21 Jun 2004 23:23:27 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newbie question : string manipulation with VBscript.

2. string manipulation with VBScript

3. String Manipulation with VBScript

4. Looking for a yearplanner-component

5. Catching the "General exception" message.

6. Can I access this database?

7. Error in StrPCopy(A,S)

8. string manipulation, string routines, etc.

9. TDateTimeField / TDateField Issue

10. heterogeneous queries

11. Q: BDE minimum install

12. Delphi/Paradox timestamp help needed

 

 
Powered by phpBB® Forum Software