[erlang-questions] RegExp Behaviour

Johnny Billquist bqt@REDACTED
Sat Apr 18 14:06:02 CEST 2009


Well, youre not thinking big enough. :-)

How about

regexp:gsub("foobarquux","o","&x").

Ie. append an "x" after each "o". Just as a small, stupid example of 
when "&" might be used/useful.

	Johnny

Gordon Guthrie wrote:
> B
> 
> How embarrassing, I read the documentation for gsub, and read and 
> re-read the regexp character stuff elsewhere in the documentation, but 
> didn't read what was staring me in the face...
> 
> However, on reading it, the phrase:
> 
> "A & in the string New is replaced by the matched
> substring of String."
> 
> leaves me completely bemused. 'on doing a substitution, don't'.
> 
> I suppose it could have some 'flow of control use'?
> 
> G
> 
> On Sat, Apr 18, 2009 at 11:28 AM, Bernard Duggan <bernie@REDACTED 
> <mailto:bernie@REDACTED>> wrote:
> 
>     I'd say it's behaving just fine.  Check the documentation for
>     regexp:sub().  "A & in the string New is replaced by the matched
>     substring of String."
> 
>     Cheers,
> 
>     B
> 
>     Gordon Guthrie wrote:
>      > Folks
>      > This looks like a bug to me, but after many years regexp still
>     gives me the
>      > creeps :(
>      >
>      >> regexp:gsub("abcde", "c", "x").
>      > {ok, "abxde", 1}
>      >
>      > One substitution, new string, tickety-boo!
>      >
>      >> regexp:gsub("ab:de", ":", "&").
>      > {ok, "ab:de", 1}
>      >
>      > One substitution, but the old string, erk?
>      >
>      > Gordon
>      >
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      > _______________________________________________
>      > erlang-questions mailing list
>      > erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>      > http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions


-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@REDACTED             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol



More information about the erlang-questions mailing list