[erlang-questions] regexp sux!

Bengt Kleberg bengt.kleberg@REDACTED
Fri Mar 9 17:10:09 CET 2007


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.


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."



More information about the erlang-questions mailing list