Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

How Can I Extract a Series of Characters Found in the Middle of a String?

(image) Hey, Scripting Guy! I have a series of strings that look something like this: xxxxyyyyyyxx. How can I extract just the y’s?-- JB(image) (image) (image) Hey, JB. And, yes, it is a Friday. But, hey, it’s just a coincidence that we happened to pick an easy question on a Friday, the day we’re itching to get out of here and go ...

How Can I Compare Two String Values Regardless of Letter Case?

(image) Hey, Scripting Guy! I have a script that compares two email addresses and tells me whether or not they are the same. Sometimes the email addresses are the same, but the case is different: for example, one address might be example@abc.com and the other might be example@ABC.com. My script always tells me that these are different email ...

How Can I Pick Out and Save Specific Lines in a Text File?

(image) Hey, Scripting Guy! I’d like to be able to read through a text file, select the lines that begin with a particular word (like Failure), and then save only those lines back to the same text file. Is there any way to do that?-- AC(image) (image) (image) Hey, AC. Hey, AC. For simplicity’s sake, we’re assuming you have a text ...

How Do I Get Rid of Extraneous Spaces in a String?

(image) I know that I can use the Split command to separate a sentence like this - VBScript is fun! - into an array of individual words. However, what happens if I have a sentence like this: VBScript is fun! I can’t use a blank space as the delimiter because I might have lots of blank spaces. And I can’t use a specific number of blank ...