[Javascript] Selecting certain areas of text in a string

Guillaume javascript at webdesignofficina.com
Fri Mar 13 07:15:26 CDT 2009


Troy, Nick, Mark,

Thank you very much for your help... I learned a lot by trying your 
suggested solutions and finally came up with a decent solution...

Troy thank you very much, you pushed me very close to where I  was 
trying to get and unlocked my problem almost entirely...

So again thank you folks !

Have a nice day.

Best regards.

Guillaume Stricher
> Hello Mr. Guillaume, 
>
> wellcome to the list.
>
>  
>
> If you arre sure that the rest of parameters will allways stay the same
>
> than you could, among other go this way:
>
>  
>
> 1. get the url of your object clip source and asign it to some var like:
>
> var my_url= //your [object].src which in this case would be:
>
> "../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10"
>
>  
>
> 2. extract the current path of the current clip that needs to be changed
>
> and asign it to some other string, like:
>
>  
>
> var curr_url = 
>
> my_url.substring( my_url.indexOf("http://"), my_url.indexOf("&autostart"));
>
> alert(curr_url); 
>
> //alertbox should display: http://www.somesite.com/video/somevideo.flv 
>
>
>  
>
> 3. Than, depending on the method you are using to compose the new
>
> source locator of a different clip, take that value and pas it to some var
>
> for replacement, or if you are setting it manually, do this:  
>
>  
>
> var new_url = 
>
> my_url.replace(curr_url,"http://www.othersite.com/video/othervideo.flv");
>
>  
>
>  
>
> alert(new_url) // will give you the full string of parameters containing
>
> the url you've now specified.
>
>  
>
> p.s.:
>
> Needless to mention, but for new source to take effect, state:  
>
> [yourobject].src = new_url;
>
>  
>
>  
>
> Regards,
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                       Troy III
>                          progressive art enterprise
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  
>
>
>
>  
>   
>> To: javascript at lists.evolt.org
>> Date: Tue, 10 Mar 2009 16:35:56 +0100
>> From: javascript at webdesignofficina.com
>> Subject: [Javascript] Selecting certain areas of text in a string
>>
>>
>> Hi there,
>>
>> Currently trying to change the url of an embedded element in a page...
>> My problem is that many other parameters are passed along the url of
>> the object, in the src property:
>>
>> src="../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10"
>>
>> I'd like to only rewrite this part: file=http://www.somesite.com/
>> video/somevideo.flv
>> Rest of the parameters should remain untouched...
>>
>> I know I should use String.replace, something like:
>>
>> var str="somevideo.flv!";
>> document.write(str.replace(/somevideo.flv/,"othervideo.flv"));
>>
>> But I have absolutely no idea on how target this piece of text only in the
>> whole src="...", starting from ending file path, from / to .flv
>>
>> Any help would be greatly appreciated.
>>
>> Thank you.
>>
>> Best regards,
>>
>> Guillaume Stricher 
>> _______________________________________________
>> Javascript mailing list
>> Javascript at lists.evolt.org
>> http://lists.evolt.org/mailman/listinfo/javascript
>>     
>
> _________________________________________________________________
> Windows Live™: Life without walls.
> http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript
>
>   




More information about the Javascript mailing list