Macromedia Flash Server - Removing port number from rtmp string

This is Interesting: Free IT Magazines  
Home > Archive > Macromedia Flash Server > April 2005 > Removing port number from rtmp string





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Removing port number from rtmp string
Stefan Richter

2005-04-27, 7:45 am

Hi guys,
I have a bit of a mental block at the moment and need some help.

Using SS Actionscript, how can I remove ':1935' from this string?

rtmp://server.domain.com:1935/mytestapp/myinst

I need to end up with
rtmp://server.domain.com/mytestapp/myinst

And it needs to reliably strip any port number from any rtmp string (which
may not even contain a port number). The string may also start with rtmpt.

SS AS can use Regular Expressions to do this kind of thing, correct? Shame
that I suck at RE's...

Thanks, anyhelp appreciated.

Stefan




=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Wouter van Vliet / WEBclusive

2005-04-28, 2:45 am

If you might want to tell me how to call Regular Expressions on the
server side (haven't looked into it, but will come in handy for me at
some moment), you can use the following:

s/^(rtmp)t?:\/\/(:\d+)?(.*)$/$1:\/\/$3/

broken down in two, you've got the following match regex:

/^(rtmp)t?:\/\/(:\d+)?(.*)$/

and this replace bit:

$1:\/\/$3

Backreferencing syntax my differ, so $1 might also be written als \\1 or \1.

Hope it helps!
Wouter

Stefan Richter wrote:
> Hi guys,
> I have a bit of a mental block at the moment and need some help.
>
> Using SS Actionscript, how can I remove ':1935' from this string?
>
> rtmp://server.domain.com:1935/mytestapp/myinst
>
> I need to end up with
> rtmp://server.domain.com/mytestapp/myinst
>
> And it needs to reliably strip any port number from any rtmp string (which
> may not even contain a port number). The string may also start with rtmpt.
>
> SS AS can use Regular Expressions to do this kind of thing, correct? Shame
> that I suck at RE's...
>
> Thanks, anyhelp appreciated.
>
> Stefan
>
>
>
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>
>
>


=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Stefan Richter

2005-04-28, 7:45 am

Thanks Wouter,
This rocks.

Now as for implementing the RE... I have never done it. But I do remember
that you can use RE's. Can anyone shed some light on this please?

Wouter, how would you use this expression in normal Javascript? I could just
try that in SS AS.

Stefan



> -----Original Message-----
> From: flashcomm-bounces-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org
> [mailto:flashcomm-bounces-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org] On Behalf Of
> Wouter van Vliet / WEBclusive
> Sent: 28 April 2005 07:16
> To: FlashComm Mailing List
> Subject: Re: [FlashComm] Removing port number from rtmp string
>
> If you might want to tell me how to call Regular Expressions
> on the server side (haven't looked into it, but will come in
> handy for me at some moment), you can use the following:
>
> s/^(rtmp)t?:\/\/(:\d+)?(.*)$/$1:\/\/$3/
>
> broken down in two, you've got the following match regex:
>
> /^(rtmp)t?:\/\/(:\d+)?(.*)$/
>
> and this replace bit:
>
> $1:\/\/$3
>
> Backreferencing syntax my differ, so $1 might also be written
> als \\1 or \1.
>
> Hope it helps!
> Wouter
>
> Stefan Richter wrote:
> also start with rtmpt.
> correct?
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>



=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Wouter van Vliet / WEBclusive

2005-04-28, 7:45 am

Yeah, I know ... ;) RegEx does rock.

As for the javascript way, it'll be:

newstr = String.replace(regex, replace);

where string is any string value, or even just "something like this"

G'luck!

Stefan Richter wrote:

>Thanks Wouter,
>This rocks.
>
>Now as for implementing the RE... I have never done it. But I do remember
>that you can use RE's. Can anyone shed some light on this please?
>
>Wouter, how would you use this expression in normal Javascript? I could just
>try that in SS AS.
>
>Stefan
>
>
>
>
>
>
>
>=-----------------------------------------------------------
>Supported by Fig Leaf Software - http://www.figleaf.com
>=-----------------------------------------------------------
>
>To change your subscription options or search the archive:
>http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>
>
>
>
>


=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com