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
Original bug ID: 1558 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Alex Baretta
Version: 3.06
OS: Linux
Submission from: host108-4.pool62211.interbusiness.it (62.211.4.108)
let bs_regexp = "\\\\" (* Matches two BS in a row )
let bs_escape_tmpl = "\" ( We want to replace matching substrings
with one single BS*)
let text = "......"
let parsed_text = Str.global_replace bs_regexp bs_escape_tmpl text;;
If I change the bs_escape_tmpl to "\\" I no longer get an exception, but
neither are my double-BS replaced by single BS--the "\\" template and the
"\\\\" regexp perform mutually trasformations on text.
Let me know...
Alex
The text was updated successfully, but these errors were encountered:
Right: the replacement text for Str.global_replace can contain <digit>
sequences, hence a backslash character in the replacement text must be
escaped (\).
If I change the bs_escape_tmpl to "\\" I no longer get an exception, but
neither are my double-BS replaced by single BS--the "\\" template and the
"\\\\" regexp perform mutually trasformations on text.
This isn't what I observe here:
let re = Str.regexp "\\\\";;
let repl = "\\";;
let text = "This is some \\ text \\ with double backslashes\n";;
print_string text;;
(* Prints: This is some \ text \ with double backslashes )
print_string (Str.global_replace re repl text);;
( Prints: This is some \ text \ with double backslashes *)
Original bug ID: 1558
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Alex Baretta
Version: 3.06
OS: Linux
Submission from: host108-4.pool62211.interbusiness.it (62.211.4.108)
let bs_regexp = "\\\\" (* Matches two BS in a row )
let bs_escape_tmpl = "\" ( We want to replace matching substrings
with one single BS*)
let text = "......"
let parsed_text = Str.global_replace bs_regexp bs_escape_tmpl text;;
---> Exception: Failure "Str.replace: illegal backslash sequence".
If I change the bs_escape_tmpl to "\\" I no longer get an exception, but
neither are my double-BS replaced by single BS--the "\\" template and the
"\\\\" regexp perform mutually trasformations on text.
Let me know...
Alex
The text was updated successfully, but these errors were encountered: