-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support regex backreferences in replace() function #1820
Comments
First of all, sorry for such a delayed response (!!). With regards to backreferences, I agree it would probably be nice to support, but I'm not sure on the interface (perl uses the syntax |
@quinnj, I created a PR for this a while back (on my phone, so it's hard to find right now). The interface I proposed wasn't liked, but it might provide some inspiration for how this could be done. |
This feature would be nice to have. I actually already thought Julia supported this but discovered Julia did not. The solution would probably be to change from PCRE to PCRE2 which seems to support this feature natively with |
@StefanKarpinski threatened to rewrite regular expressions in pure Julia at some point, but I'm pretty sure he's been busy with other things. ;-)
I suspect it's because no one in the know has found/made the time to do so. If you're up to it, why don't you open a separate, feeler issue, to see if there is interest, and if so (and if you have time), submit such a PR? |
I haven't had a strong need for regular expressions recently, but while you're at it, the interface itself could also use some love. It's one of the oldest interfaces, and it's type unstable--returning |
Since Julia recently have bumped to use PCRE2 I have wrapped the
|
Hi,
It is very useful to be able to replace a string using matches from a regex capture group. For example:
julia> replace("a=5", r"(\w+)=(\d+)", L"\1=35")
a=35
Perlre also allow backreferences in the pattern but that isn't as commonly used as backreference in the replacement string. Search for backreference here for more info:
http://perldoc.perl.org/perlre.html
Glen
The text was updated successfully, but these errors were encountered: