Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003778OCamlotherlibspublic2005-08-31 16:302016-12-07 18:10
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0003778: \\2 in global_replace
DescriptionFull_Name: mattias waldau
Version: 3084
Submission from: (

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.


1. Introduce a simple search-replace function that replace a substring with
another substring without any use of regexp or templ

2. Introduce a function quote_tmpl that quotes \\ and mention it in the
documentation of global_replace and substitute_first

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2016-12-07 18:10 shinwell Category OCaml general => OCaml otherlibs
2016-12-07 18:10 shinwell Description Updated View Revisions
2017-02-23 16:42 doligez Category OCaml otherlibs => otherlibs

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker