
Get Page Title (RegExp Q)
Oh, ok. I see. Sorry about that. I was just under the
impression that it was for the web. Thanks.
WasConfused
Quote:
>-----Original Message-----
>Because this would not be done using the browser, but
using a standalone js
Quote:
>file.
>s in getTitle(s) would be the result of file access via
the FileSystemObject
Quote:
>and the TextStream Object (there are articles on the web
on doing this). The
>function will be performed on more than one file.
message
>> I am confused, why wouldn't you just use
document.title??
>> Sorry for the ignorance.
>> Confused
>> >-----Original Message-----
>> >I have found the following script (I have modified it
>> slightly) for getting
>> >a page title from a string (from a webpage) at
>http://www.infinitemonkeys.ws/infinitemonkeys/articles/asp
>> /971.asp
>> >function getTitle(s) {
>> > var objReg = /<title.*>[\n]*(.*)[\n]*<\/title>/gi;
>> > if(objReg.exec(s)!=null){
>> > if(RegExp.lastParen=="") return "Untitled"
>> > return RegExp.lastParen;
>> > } else {
>> > return 'undefined';
>> > }
>> >}
>> >However it does not work if the title is on several
lines.
>> >I want the function to return 'Page Title' for both (1)
>> and (2)
>> >(1)
>> ><title lang=en>
>> >Page
>> >Title
>> ></title>
>> >(2)
>> ><title>Page Title</title>
>> >.
>.