No, I mean /$\s*^/g which looks for any whitespace (including \n and \r)
between the end of a line and the beginning of the next (with the /g) so you
replace that with "". But for some reason that won't work in Flex's regexp
implementation although it does work fine in Java's. The second solution
works fine though:
var s : String = "Line\nLine2";
var rg : RegExp = /$\s*^/g;
trace("s == \"" + s + "\"");
trace("");
trace("s.replace(" + rg + ",\"\") == \"" + s.replace(rg,"")
+ "\"");
trace("");
trace("s.split(\"\\n\").join(\"\") == \"" +
s.split("\n").join("") + "\"");
trace("");
Gives:
s == "Line
Line2"
s.replace(/$\s*^/g,"") == "Line
Line2"
s.split("\n").join("") == "LineLine2"
-Josh
On Wed, Jun 18, 2008 at 9:36 AM, Luke Vanderfluit <
[EMAIL PROTECTED]> wrote:
> Hi.
>
> Thanks for your help.
>
> Josh McDonald wrote:
> > If the /$\s*^/g regex doesn't work (it should though),
>
> You probably mean /^\s*$/ which is looking for any number of spaces between
> the beginning
> and end of a line...
>
> try
> > string.split("\n").join("") - it probably won't be fast,
> problem is I cant get it to recognise the "\n"
>
> Kr.
> Luke.
>
> but it'll get
> > you by, and you can write something specific using indexOf etc later if
> > speed becomes a problem.
> >
> > -Josh
> >
> > On Wed, Jun 18, 2008 at 9:24 AM, Luke Vanderfluit
> > <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Hi.
> >
> > shaun etherton wrote:
> > > Hey Luke,
> > >
> > > Luke Vanderfluit wrote:
> > >> Ive tried this:
> > >> var myp:RegExp = /\n/g;
> > >
> > > have you tried \r
> >
> > Yes. Ive tried /\r\n/, /\r/, /\n/
> > Also tried setting is as in new RegExp("//n","g"); etc.
> >
> > Kr.
> > Luke.
> >
> > >
> > > cheers,
> >
> >
> > --
> > Luke Vanderfluit
> > Analyst / Web Programmer
> > e3Learning.com.au <http://e3Learning.com.au>
> > 08 8221 6422
> >
> > ------------------------------------
> >
> > --
> > Flexcoders Mailing List
> > FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo!
> > Groups Links
> >
> >
> > mailto:[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>
> >
> >
> >
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for thee."
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>
>
> --
> Luke Vanderfluit
> Analyst / Web Programmer
> e3Learning.com.au
> 08 8221 6422
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]