[erlang-questions] regexp sux!

Michael McDaniel erlangx@REDACTED
Fri Mar 9 19:10:31 CET 2007


On Fri, Mar 09, 2007 at 05:10:09PM +0100, Bengt Kleberg wrote:
> On 2007-03-09 16:54, Michael McDaniel wrote:
> 
> >   here is one way to get encoding ver w/regexp, though not
> >   fully reliable due to depending on fixed version length
> >   and depending on no whitespace between endcoding= and the
> >   version.
> >   
> > 
> >  1>  X="<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>".
> >  "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"
> > 
> >  2> {match, Start, Length} = regexp:match(X, "encoding=").
> >  {match,21,9}
> 
> perhas you could use
> Start = string:str(X, "encoding=")
> instead?
> that would make no use of regexp at all.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  ooohhh, I like that - thanks!  may be time to refactor some
  of my code ...

~M

> 
> 
> bengt
> -- 
> Those were the days...
>     EPO guidelines 1978: "If the contribution to the known art resides
>     solely in a computer program then the subject matter is not
>     patentable in whatever manner it may be presented in the claims."
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> !DSPAM:52,45f1875118347744713486!
> 
> 



More information about the erlang-questions mailing list