You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm afraid no-one has managed to implement this in the past 15 years. Given that there is a workaround (which actually isn't that uncommon -- I looked at Jane Street's re2 library and the interface was very similar in this regard), I'm closing this issue.
Original bug ID: 3778
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: otherlibs
Bug description
Full_Name: mattias waldau
Version: 3084
OS: WinXP
Submission from: c-328ae253.09-253-7570701.cust.bredbandsbolaget.se (83.226.138.50)
Got bitten by the \2 feature of global_replace. I had code that substitute in a
string from the user into a string and it contained \, i.e.
replace_first (String.regexp_string "{1}") "new_hire_training1\2" txt
and of course it failed. The solution is of course to use substitute_first
instead, i.e.
substitute_first arg1_regexp (fun _ -> "new_hire_training1\2") txt
Although this is of course a bit overkill for a simple search-replace.
Suggestion:
Introduce a simple search-replace function that replace a substring with
another substring without any use of regexp or templ
Introduce a function quote_tmpl that quotes \ and mention it in the
documentation of global_replace and substitute_first
The text was updated successfully, but these errors were encountered: